readline: add variables option
Also add a basic test case.
This commit is contained in:
parent
bb5dea02b9
commit
284b8d94d4
5 changed files with 72 additions and 1 deletions
|
|
@ -6,6 +6,19 @@ let
|
|||
|
||||
cfg = config.programs.readline;
|
||||
|
||||
mkSetVariableStr = n: v:
|
||||
let
|
||||
mkValueStr = v:
|
||||
if v == true then "on"
|
||||
else if v == false then "off"
|
||||
else if isInt v then toString v
|
||||
else if isString v then v
|
||||
else abort ("values ${toPretty v} is of unsupported type");
|
||||
in
|
||||
"set ${n} ${mkValueStr v}";
|
||||
|
||||
mkBindingStr = k: v: "\"${k}\": ${v}";
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
|
@ -19,6 +32,15 @@ in
|
|||
description = "Readline bindings.";
|
||||
};
|
||||
|
||||
variables = mkOption {
|
||||
type = with types; attrsOf (either str (either int bool));
|
||||
default = {};
|
||||
example = { expand-tilde = true; };
|
||||
description = ''
|
||||
Readline customization variable assignments.
|
||||
'';
|
||||
};
|
||||
|
||||
includeSystemConfig = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
|
|
@ -40,7 +62,8 @@ in
|
|||
let
|
||||
configStr = concatStringsSep "\n" (
|
||||
optional cfg.includeSystemConfig "$include /etc/inputrc"
|
||||
++ mapAttrsToList (k: v: "\"${k}\": ${v}") cfg.bindings
|
||||
++ mapAttrsToList mkSetVariableStr cfg.variables
|
||||
++ mapAttrsToList mkBindingStr cfg.bindings
|
||||
);
|
||||
in
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue