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 . xresources ; 8 9formatLine = n :v : 10let 11formatList = x : 12if isList x then 13throw "can not convert 2-dimensional lists to Xresources format" 14else 15formatValue x ; 16 17formatValue = v : 18if isBool v then 19( if v then "true" else "false" ) 20else if isList v then 21concatMapStringsSep ", " formatList v 22else 23toString v ; 24in " ${ n } : ${ formatValue v } " ; 25 26xrdbMerge = " ${ pkgs . xorg . xrdb } /bin/xrdb -merge ${ cfg . path } " ; 27 28in { 29meta . maintainers = [ maintainers . rycee ]; 30 31options = { 32xresources . properties = mkOption { 33type = with types ; 34let 35prim = either bool ( either int str ); 36entry = either prim ( listOf prim ); 37in nullOr ( attrsOf entry ); 38default = null ; 39example = literalExpression '' 40{ 41"Emacs*toolBar" = 0; 42"XTerm*faceName" = "dejavu sans mono"; 43"XTerm*charClass" = [ "37:48" "45-47:48" "58:48" "64:48" "126:48" ]; 44} 45'' ; 46description = '' 47X server resources that should be set. 48Booleans are formatted as "true" or "false" respectively. 49List elements are recursively formatted as a string and joined by commas. 50All other values are directly formatted using builtins.toString. 51Note, that 2-dimensional lists are not supported and specifying one will throw an exception. 52If this and all other xresources options are 53`null`, then this feature is disabled and no 54{file}`~/.Xresources` link is produced. 55'' ; 56}; 57 58xresources . extraConfig = mkOption { 59type = types . lines ; 60default = "" ; 61example = literalExpression '' 62builtins.readFile ( 63pkgs.fetchFromGitHub { 64owner = "solarized"; 65repo = "xresources"; 66rev = "025ceddbddf55f2eb4ab40b05889148aab9699fc"; 67sha256 = "0lxv37gmh38y9d3l8nbnsm1mskcv10g3i83j0kac0a2qmypv1k9f"; 68} + "/Xresources.dark" 69) 70'' ; 71description = '' 72Additional X server resources contents. 73If this and all other xresources options are 74`null`, then this feature is disabled and no 75{file}`~/.Xresources` link is produced. 76'' ; 77}; 78 79xresources . path = mkOption { 80type = types . str ; 81default = " ${ config . home . homeDirectory } /.Xresources" ; 82defaultText = "$HOME/.Xresources" ; 83description = 84"Path where Home Manager should link the {file}`.Xresources` file." ; 85}; 86}; 87 88config = mkIf (( cfg . properties != null && cfg . properties != { }) 89|| cfg . extraConfig != "" ) { 90home . file .${ cfg . path } = { 91text = concatStringsSep "\n" ([ ] 92++ optional ( cfg . extraConfig != "" ) cfg . extraConfig 93++ optionals ( cfg . properties != null ) 94( mapAttrsToList formatLine cfg . properties )) + "\n" ; 95onChange = '' 96if [[ -v DISPLAY ]]; then 97${ xrdbMerge } 98fi 99'' ; 100}; 101 102xsession . initExtra = xrdbMerge ; 103}; 104}