1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-05 01:19:46 +01:00
home-manager/modules/programs/readline.nix
Vojtěch Káně 2b71762384
readline: add module
Add basic readline configuration (~/.inputrc) management.

(cherry picked from commit bb5dea02b9)
2020-02-16 18:08:07 +01:00

53 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.readline;
in
{
options.programs.readline = {
enable = mkEnableOption "readline";
bindings = mkOption {
default = {};
type = types.attrsOf types.str;
example = { "\C-h" = "backward-kill-word"; };
description = "Readline bindings.";
};
includeSystemConfig = mkOption {
type = types.bool;
default = true;
description = "Whether to include the system-wide configuration.";
};
extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Configuration lines appended unchanged to the end of the
<filename>~/.inputrc</filename> file.
'';
};
};
config = mkIf cfg.enable {
home.file.".inputrc".text =
let
configStr = concatStringsSep "\n" (
optional cfg.includeSystemConfig "$include /etc/inputrc"
++ mapAttrsToList (k: v: "\"${k}\": ${v}") cfg.bindings
);
in
''
# Generated by Home Manager.
${configStr}
${cfg.extraConfig}
'';
};
}