1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-14 07:09:45 +01:00

readline: optionally place config file in XDG dir

Based on PR #4189
This commit is contained in:
Shaw Vrana 2024-03-27 16:03:27 -07:00 committed by Mikilio
parent 6f97ea6369
commit 294f6c9257
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
4 changed files with 49 additions and 4 deletions

View file

@ -473,6 +473,12 @@ in
will be printed when the user configuration is being built. will be printed when the user configuration is being built.
''; '';
}; };
home.preferXdgDirectories = mkEnableOption "" // {
description = ''
Whether to make programs use XDG directories whenever supported.
'';
};
}; };
config = { config = {

View file

@ -68,8 +68,8 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable (let
home.file.".inputrc".text = let finalConfig = let
configStr = concatStringsSep "\n" configStr = concatStringsSep "\n"
(optional cfg.includeSystemConfig "$include /etc/inputrc" (optional cfg.includeSystemConfig "$include /etc/inputrc"
++ mapAttrsToList mkSetVariableStr cfg.variables ++ mapAttrsToList mkSetVariableStr cfg.variables
@ -80,5 +80,13 @@ in {
${configStr} ${configStr}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
}; in 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";
})
]);
} }

View file

@ -1 +1,4 @@
{ readline-using-all-options = ./using-all-options.nix; } {
readline-using-all-options = ./using-all-options.nix;
readline-prefer-xdg-dirs = ./prefer-xdg-dirs.nix;
}

View file

@ -0,0 +1,28 @@
{ ... }:
{
home.preferXdgDirectories = true;
programs.readline = {
enable = true;
variables.bell-style = "audible";
};
nmt.script = ''
assertFileContent \
home-files/.config/inputrc \
${
builtins.toFile "readline-expected" ''
# Generated by Home Manager.
$include /etc/inputrc
set bell-style audible
''
}
assertFileContains \
home-path/etc/profile.d/hm-session-vars.sh \
'export INPUTRC="/home/hm-user/.config/inputrc"'
'';
}