fork/home-manager
git clone https://git.julia.blue/fork/home-manager
17dc5939
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . stalonetray ; 8 9in { 10options = { 11services . stalonetray = { 12enable = mkEnableOption "Stalonetray system tray" ; 13 14package = mkOption { 15default = pkgs . stalonetray ; 16defaultText = literalExpression "pkgs.stalonetray" ; 17type = types . package ; 18example = literalExpression "pkgs.stalonetray" ; 19description = "The package to use for the Stalonetray binary." ; 20}; 21 22config = mkOption { 23type = with types ; attrsOf ( nullOr ( either str ( either bool int ))); 24description = '' 25Stalonetray configuration as a set of attributes. 26'' ; 27default = { }; 28example = { 29geometry = "3x1-600+0" ; 30decorations = null ; 31icon_size = 30 ; 32sticky = true ; 33background = "#cccccc" ; 34}; 35}; 36 37extraConfig = mkOption { 38type = types . lines ; 39description = "Additional configuration lines for stalonetrayrc." ; 40default = "" ; 41example = '' 42geometry 3x1-600+0 43decorations none 44icon_size 30 45sticky true 46background "#cccccc" 47'' ; 48}; 49}; 50}; 51 52config = mkIf cfg . enable ( mkMerge [ 53{ 54assertions = [ 55( hm . assertions . assertPlatform "services.stalonetray" pkgs 56platforms . linux ) 57]; 58 59home . packages = [ cfg . package ]; 60 61systemd . user . services . stalonetray = { 62Unit = { 63Description = "Stalonetray system tray" ; 64PartOf = [ "tray.target" ]; 65}; 66 67Install = { WantedBy = [ "tray.target" ]; }; 68 69Service = { 70ExecStart = " ${ cfg . package } /bin/stalonetray" ; 71Restart = "on-failure" ; 72}; 73}; 74} 75 76( mkIf ( cfg . config != { }) { 77home . file . ".stalonetrayrc" . text = let 78valueToString = v : 79if isBool v then 80( if v then "true" else "false" ) 81else if ( v == null ) then 82"none" 83else 84''" ${ toString v } "'' ; 85in concatStrings ( mapAttrsToList ( k :v :'' 86${ k } ${ valueToString v } 87'' ) cfg . config ); 88}) 89 90( mkIf ( cfg . extraConfig != "" ) { 91home . file . ".stalonetrayrc" . text = cfg . extraConfig ; 92}) 93]); 94}