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 . programs . readline ; 8 9mkSetVariableStr = n :v : 10let 11mkValueStr = v : 12if v == true then 13"on" 14else if v == false then 15"off" 16else if isInt v then 17toString v 18else if isString v then 19v 20else 21abort ( "values ${ toPretty v } is of unsupported type" ); 22in "set ${ n } ${ mkValueStr v } " ; 23 24mkBindingStr = k :v : 25let 26isKeynameNotKeyseq = k : 27builtins . elem ( builtins . head ( lib . splitString "-" ( toLower k ))) [ 28"control" 29"meta" 30]; 31in if isKeynameNotKeyseq k then " ${ k } : ${ v } " else ''" ${ k } ": ${ v } '' ; 32 33in { 34options . programs . readline = { 35enable = mkEnableOption "readline" ; 36 37bindings = mkOption { 38default = { }; 39type = types . attrsOf types . str ; 40example = literalExpression '' 41{ "\\C-h" = "backward-kill-word"; } 42'' ; 43description = "Readline bindings." ; 44}; 45 46variables = mkOption { 47type = with types ; attrsOf ( either str ( either int bool )); 48default = { }; 49example = { expand-tilde = true ; }; 50description = '' 51Readline customization variable assignments. 52'' ; 53}; 54 55includeSystemConfig = mkOption { 56type = types . bool ; 57default = true ; 58description = "Whether to include the system-wide configuration." ; 59}; 60 61extraConfig = mkOption { 62type = types . lines ; 63default = "" ; 64description = '' 65Configuration lines appended unchanged to the end of the 66{file}`~/.inputrc` file. 67'' ; 68}; 69}; 70 71config = mkIf cfg . enable { 72home . file . ".inputrc" . text = let 73configStr = concatStringsSep "\n" 74( optional cfg . includeSystemConfig "$include /etc/inputrc" 75++ mapAttrsToList mkSetVariableStr cfg . variables 76++ mapAttrsToList mkBindingStr cfg . bindings ); 77in '' 78# Generated by Home Manager. 79 80${ configStr } 81${ cfg . extraConfig } 82'' ; 83}; 84}