fork/home-manager
git clone https://git.julia.blue/fork/home-manager
4fa1ba72
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6cfg = config . services . dwm-status ; 7 8jsonFormat = pkgs . formats . json { }; 9 10features = [ "audio" "backlight" "battery" "cpu_load" "network" "time" ]; 11 12finalConfig = { inherit ( cfg ) order ; } // cfg . extraConfig ; 13 14configFile = jsonFormat . generate "dwm-status.json" finalConfig ; 15 16in { 17options = { 18services . dwm-status = { 19enable = mkEnableOption "dwm-status user service" ; 20 21package = mkOption { 22type = types . package ; 23default = pkgs . dwm-status ; 24defaultText = literalExpression "pkgs.dwm-status" ; 25example = "pkgs.dwm-status.override { enableAlsaUtils = false; }" ; 26description = "Which dwm-status package to use." ; 27}; 28 29order = mkOption { 30type = types . listOf ( types . enum features ); 31description = "List of enabled features in order." ; 32}; 33 34extraConfig = mkOption { 35type = jsonFormat . type ; 36default = { }; 37example = literalExpression '' 38{ 39separator = "#"; 40 41battery = { 42notifier_levels = [ 2 5 10 15 20 ]; 43}; 44 45time = { 46format = "%H:%M"; 47}; 48} 49'' ; 50description = "Extra config of dwm-status." ; 51}; 52}; 53}; 54 55config = mkIf cfg . enable { 56assertions = [ 57( lib . hm . assertions . assertPlatform "services.dwm-status" pkgs 58lib . platforms . linux ) 59]; 60 61systemd . user . services . dwm-status = { 62Unit = { 63Description = "DWM status service" ; 64PartOf = [ "graphical-session.target" ]; 65}; 66 67Install = { WantedBy = [ "graphical-session.target" ]; }; 68 69Service = { ExecStart = " ${ cfg . package } /bin/dwm-status ${ configFile } " ; }; 70}; 71}; 72}