fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . xsettingsd ; 8 9renderSettings = settings : 10concatStrings ( mapAttrsToList renderSetting settings ); 11 12renderSetting = key :value :'' 13${ key } ${ renderValue value } 14'' ; 15 16renderValue = value : 17{ 18int = toString value ; 19bool = if value then "1" else "0" ; 20string = ''" ${ value } "'' ; 21}.${ builtins . typeOf value }; 22 23in { 24meta . maintainers = [ maintainers . imalison ]; 25 26options = { 27services . xsettingsd = { 28enable = mkEnableOption "xsettingsd" ; 29 30package = mkOption { 31type = types . package ; 32default = pkgs . xsettingsd ; 33defaultText = literalExpression "pkgs.xsettingsd" ; 34description = '' 35Package containing the {command}`xsettingsd` program. 36'' ; 37}; 38 39settings = mkOption { 40type = with types ; attrsOf ( oneOf [ bool int str ]); 41default = { }; 42example = literalExpression '' 43{ 44"Net/ThemeName" = "Numix"; 45"Xft/Antialias" = true; 46"Xft/Hinting" = true; 47"Xft/RGBA" = "rgb"; 48} 49'' ; 50description = '' 51Xsettingsd options for configuration file. See 52<https://github.com/derat/xsettingsd/wiki/Settings> 53for documentation on these values. 54'' ; 55}; 56 57configFile = mkOption { 58type = types . nullOr types . package ; 59internal = true ; 60readOnly = true ; 61default = if cfg . settings == { } then 62null 63else 64pkgs . writeText "xsettingsd.conf" ( renderSettings cfg . settings ); 65}; 66}; 67}; 68 69config = mkIf cfg . enable { 70assertions = [ 71( lib . hm . assertions . assertPlatform "services.xsettingsd" pkgs 72lib . platforms . linux ) 73]; 74 75systemd . user . services . xsettingsd = { 76Unit = { 77Description = "xsettingsd" ; 78After = [ "graphical-session-pre.target" ]; 79PartOf = [ "graphical-session.target" ]; 80}; 81 82Install . WantedBy = [ "graphical-session.target" ]; 83 84Service = { 85Environment = "PATH= ${ config . home . profileDirectory } /bin" ; 86ExecStart = " ${ cfg . package } /bin/xsettingsd" 87+ optionalString ( cfg . configFile != null ) 88" -c ${ escapeShellArg cfg . configFile } " ; 89Restart = "on-abort" ; 90}; 91}; 92}; 93}