1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.dwm-status;
7
8 order = concatMapStringsSep "," (feature: ''"${feature}"'') cfg.order;
9
10 configFile = pkgs.writeText "dwm-status.toml" ''
11 order = [${order}]
12
13 ${cfg.extraConfig}
14 '';
15in
16
17{
18
19 ###### interface
20
21 options = {
22
23 services.dwm-status = {
24
25 enable = mkEnableOption "dwm-status user service";
26
27 package = mkPackageOption pkgs "dwm-status" {
28 example = "dwm-status.override { enableAlsaUtils = false; }";
29 };
30
31 order = mkOption {
32 type = types.listOf (types.enum [ "audio" "backlight" "battery" "cpu_load" "network" "time" ]);
33 description = ''
34 List of enabled features in order.
35 '';
36 };
37
38 extraConfig = mkOption {
39 type = types.lines;
40 default = "";
41 description = ''
42 Extra config in TOML format.
43 '';
44 };
45
46 };
47
48 };
49
50
51 ###### implementation
52
53 config = mkIf cfg.enable {
54
55 services.upower.enable = elem "battery" cfg.order;
56
57 systemd.user.services.dwm-status = {
58 description = "Highly performant and configurable DWM status service";
59 wantedBy = [ "graphical-session.target" ];
60 partOf = [ "graphical-session.target" ];
61
62 serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile}";
63 };
64
65 };
66
67}