mirror of
https://github.com/nix-community/home-manager
synced 2024-12-02 16:09:46 +01:00
readline: add variables option
Also add a basic test case.
(cherry picked from commit 284b8d94d4
)
This commit is contained in:
parent
2b71762384
commit
3166ae7993
5 changed files with 72 additions and 1 deletions
|
@ -6,6 +6,19 @@ let
|
||||||
|
|
||||||
cfg = config.programs.readline;
|
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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -19,6 +32,15 @@ in
|
||||||
description = "Readline bindings.";
|
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 {
|
includeSystemConfig = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -40,7 +62,8 @@ in
|
||||||
let
|
let
|
||||||
configStr = concatStringsSep "\n" (
|
configStr = concatStringsSep "\n" (
|
||||||
optional cfg.includeSystemConfig "$include /etc/inputrc"
|
optional cfg.includeSystemConfig "$include /etc/inputrc"
|
||||||
++ mapAttrsToList (k: v: "\"${k}\": ${v}") cfg.bindings
|
++ mapAttrsToList mkSetVariableStr cfg.variables
|
||||||
|
++ mapAttrsToList mkBindingStr cfg.bindings
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
|
|
|
@ -46,6 +46,7 @@ import nmt {
|
||||||
// import ./modules/programs/alacritty
|
// import ./modules/programs/alacritty
|
||||||
// import ./modules/programs/bash
|
// import ./modules/programs/bash
|
||||||
// import ./modules/programs/gpg
|
// import ./modules/programs/gpg
|
||||||
|
// import ./modules/programs/readline
|
||||||
// import ./modules/programs/ssh
|
// import ./modules/programs/ssh
|
||||||
// import ./modules/programs/tmux
|
// import ./modules/programs/tmux
|
||||||
// import ./modules/programs/zsh;
|
// import ./modules/programs/zsh;
|
||||||
|
|
3
tests/modules/programs/readline/default.nix
Normal file
3
tests/modules/programs/readline/default.nix
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
readline-using-all-options = ./using-all-options.nix;
|
||||||
|
}
|
33
tests/modules/programs/readline/using-all-options.nix
Normal file
33
tests/modules/programs/readline/using-all-options.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.readline = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
bindings = {
|
||||||
|
"\C-h" = "backward-kill-word";
|
||||||
|
};
|
||||||
|
|
||||||
|
variables = {
|
||||||
|
bell-style = "audible";
|
||||||
|
completion-map-case = true;
|
||||||
|
completion-prefix-display-length = 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = ''
|
||||||
|
$if mode=emacs
|
||||||
|
"\e[1~": beginning-of-line
|
||||||
|
$endif
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileContent \
|
||||||
|
home-files/.inputrc \
|
||||||
|
${./using-all-options.txt}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
11
tests/modules/programs/readline/using-all-options.txt
Normal file
11
tests/modules/programs/readline/using-all-options.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# Generated by Home Manager.
|
||||||
|
|
||||||
|
$include /etc/inputrc
|
||||||
|
set bell-style audible
|
||||||
|
set completion-map-case on
|
||||||
|
set completion-prefix-display-length 2
|
||||||
|
"C-h": backward-kill-word
|
||||||
|
$if mode=emacs
|
||||||
|
"\e[1~": beginning-of-line
|
||||||
|
$endif
|
||||||
|
|
Loading…
Reference in a new issue