nixpkgs/nixos/modules/services/misc/dwm-status.nix

87 lines
2.1 KiB
Nix
Raw Permalink Normal View History

{
config,
lib,
pkgs,
...
}:
2018-12-01 17:32:21 +01:00
let
cfg = config.services.dwm-status;
format = pkgs.formats.toml { };
2018-12-01 17:32:21 +01:00
configFile = format.generate "dwm-status.toml" cfg.settings;
2018-12-01 17:32:21 +01:00
in
{
imports = [
(lib.mkRenamedOptionModule
[ "services" "dwm-status" "order" ]
[ "services" "dwm-status" "settings" "order" ]
)
(lib.mkRemovedOptionModule [
"services"
"dwm-status"
"extraConfig"
] "Use services.dwm-status.settings instead.")
];
2018-12-01 17:32:21 +01:00
options = {
services.dwm-status = {
enable = lib.mkEnableOption "dwm-status user service";
2018-12-01 17:32:21 +01:00
package = lib.mkPackageOption pkgs "dwm-status" {
example = "dwm-status.override { enableAlsaUtils = false; }";
2018-12-01 17:32:21 +01:00
};
settings = lib.mkOption {
type = lib.types.submodule {
freeformType = format.type;
options.order = lib.mkOption {
type = lib.types.listOf (
lib.types.enum [
"audio"
"backlight"
"battery"
"cpu_load"
"network"
"time"
]
);
default = [ ];
description = ''
List of enabled features in order.
'';
};
};
default = { };
example = {
order = [
"battery"
"cpu_load"
"time"
];
time = {
format = "%F %a %r";
update_seconds = true;
};
};
description = ''
Config options for dwm-status, see https://github.com/Gerschtli/dwm-status#configuration
for available options.
2018-12-01 17:32:21 +01:00
'';
};
};
};
config = lib.mkIf cfg.enable {
services.upower.enable = lib.mkIf (lib.elem "battery" cfg.settings.order) true;
2018-12-01 17:32:21 +01:00
systemd.user.services.dwm-status = {
description = "Highly performant and configurable DWM status service";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
2025-05-27 18:59:36 +02:00
serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile} --quiet";
2018-12-01 17:32:21 +01:00
};
};
}