about summary refs log tree commit diff
path: root/nixos/modules/services
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2019-08-09 15:39:50 +0200
committerGitHub <noreply@github.com>2019-08-09 15:39:50 +0200
commit013d403f3023c7915a3af3a00548c0cdf7eac7f9 (patch)
tree26499b38f2d17668f3a96bfb2a69af3f3af33c26 /nixos/modules/services
parent6be96fbd4a7297685ae20dbd4dc5724e107afa90 (diff)
parent003b42f33241229dc9094d713f4e88bff9d72d14 (diff)
downloadnixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.tar
nixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.tar.gz
nixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.tar.bz2
nixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.tar.lz
nixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.tar.xz
nixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.tar.zst
nixlib-013d403f3023c7915a3af3a00548c0cdf7eac7f9.zip
nixos/dwm-status: add module (#51319)
nixos/dwm-status: add module
Diffstat (limited to 'nixos/modules/services')
-rw-r--r--nixos/modules/services/misc/dwm-status.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/dwm-status.nix b/nixos/modules/services/misc/dwm-status.nix
new file mode 100644
index 000000000000..b98a42e6a6d2
--- /dev/null
+++ b/nixos/modules/services/misc/dwm-status.nix
@@ -0,0 +1,73 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.dwm-status;
+
+  order = concatMapStringsSep "," (feature: ''"${feature}"'') cfg.order;
+
+  configFile = pkgs.writeText "dwm-status.toml" ''
+    order = [${order}]
+
+    ${cfg.extraConfig}
+  '';
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.dwm-status = {
+
+      enable = mkEnableOption "dwm-status user service";
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.dwm-status;
+        defaultText = "pkgs.dwm-status";
+        example = "pkgs.dwm-status.override { enableAlsaUtils = false; }";
+        description = ''
+          Which dwm-status package to use.
+        '';
+      };
+
+      order = mkOption {
+        type = types.listOf (types.enum [ "audio" "backlight" "battery" "cpu_load" "network" "time" ]);
+        description = ''
+          List of enabled features in order.
+        '';
+      };
+
+      extraConfig = mkOption {
+        type = types.lines;
+        default = "";
+        description = ''
+          Extra config in TOML format.
+        '';
+      };
+
+    };
+
+  };
+
+
+  ###### implementation
+
+  config = mkIf cfg.enable {
+
+    services.upower.enable = elem "battery" cfg.order;
+
+    systemd.user.services.dwm-status = {
+      description = "Highly performant and configurable DWM status service";
+      wantedBy = [ "graphical-session.target" ];
+      partOf = [ "graphical-session.target" ];
+
+      serviceConfig.ExecStart = "${cfg.package}/bin/dwm-status ${configFile}";
+    };
+
+  };
+
+}