1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

treewide: reformat nixfmt-rfc-style

Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
Austin Horstman 2025-04-07 16:11:29 -05:00
parent 5df48c4255
commit cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions

View file

@ -4,9 +4,11 @@ let
cfg = config.programs.readline;
mkSetVariableStr = n: v:
mkSetVariableStr =
n: v:
let
mkValueStr = v:
mkValueStr =
v:
if v == true then
"on"
else if v == false then
@ -17,18 +19,23 @@ let
v
else
abort "values ${lib.toPretty v} is of unsupported type";
in "set ${n} ${mkValueStr v}";
in
"set ${n} ${mkValueStr v}";
mkBindingStr = k: v:
mkBindingStr =
k: v:
let
isKeynameNotKeyseq = k:
isKeynameNotKeyseq =
k:
builtins.elem (builtins.head (lib.splitString "-" (lib.toLower k))) [
"control"
"meta"
];
in if isKeynameNotKeyseq k then "${k}: ${v}" else ''"${k}": ${v}'';
in
if isKeynameNotKeyseq k then "${k}: ${v}" else ''"${k}": ${v}'';
in {
in
{
options.programs.readline = {
enable = lib.mkEnableOption "readline";
@ -44,7 +51,9 @@ in {
variables = mkOption {
type = with types; attrsOf (either str (either int bool));
default = { };
example = { expand-tilde = true; };
example = {
expand-tilde = true;
};
description = ''
Readline customization variable assignments.
'';
@ -66,25 +75,31 @@ in {
};
};
config = mkIf cfg.enable (let
finalConfig = let
configStr = lib.concatStringsSep "\n"
(lib.optional cfg.includeSystemConfig "$include /etc/inputrc"
++ lib.mapAttrsToList mkSetVariableStr cfg.variables
++ lib.mapAttrsToList mkBindingStr cfg.bindings);
in ''
# Generated by Home Manager.
config = mkIf cfg.enable (
let
finalConfig =
let
configStr = lib.concatStringsSep "\n" (
lib.optional cfg.includeSystemConfig "$include /etc/inputrc"
++ lib.mapAttrsToList mkSetVariableStr cfg.variables
++ lib.mapAttrsToList mkBindingStr cfg.bindings
);
in
''
# Generated by Home Manager.
${configStr}
${cfg.extraConfig}
'';
in lib.mkMerge [
(mkIf (!config.home.preferXdgDirectories) {
home.file.".inputrc".text = finalConfig;
})
(mkIf config.home.preferXdgDirectories {
xdg.configFile.inputrc.text = finalConfig;
home.sessionVariables.INPUTRC = "${config.xdg.configHome}/inputrc";
})
]);
${configStr}
${cfg.extraConfig}
'';
in
lib.mkMerge [
(mkIf (!config.home.preferXdgDirectories) {
home.file.".inputrc".text = finalConfig;
})
(mkIf config.home.preferXdgDirectories {
xdg.configFile.inputrc.text = finalConfig;
home.sessionVariables.INPUTRC = "${config.xdg.configHome}/inputrc";
})
]
);
}