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