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 (lib.mdDoc "dwm-status user service");
26
27 package = mkOption {
28 type = types.package;
29 default = pkgs.dwm-status;
30 defaultText = literalExpression "pkgs.dwm-status";
31 example = literalExpression "pkgs.dwm-status.override { enableAlsaUtils = false; }";
32 description = lib.mdDoc ''
33 Which dwm-status package to use.
34 '';
35 };
36
37 order = mkOption {
38 type = types.listOf (types.enum [ "audio" "backlight" "battery" "cpu_load" "network" "time" ]);
39 description = lib.mdDoc ''
40 List of enabled features in order.
41 '';
42 };
43
44 extraConfig = mkOption {
45 type = types.lines;
46 default = "";
47 description = lib.mdDoc ''
48 Extra config in TOML format.
49 '';
50 };
51
52 };
53
54 };
55
56
57 ###### implementation
58
59 config = mkIf cfg.enable {
60
61 services.upower.enable = elem "battery" cfg.order;
62
63 systemd.user.services.dwm-status = {
64 description = "Highly performant and configurable DWM status service";
65 wantedBy = [ "graphical-session.target" ];
66 partOf = [ "graphical-session.target" ];
67
68 serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile}";
69 };
70
71 };
72
73}