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

bash: Make sure HISTFILE's directory exists

Co-authored-by: Robert Helgesson <robert@rycee.net>
This commit is contained in:
Damien Cassou 2025-01-12 18:09:08 +01:00 committed by Robert Helgesson
parent 15bd673658
commit f99c704fe3
3 changed files with 24 additions and 2 deletions

View file

@ -180,7 +180,7 @@ in {
sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;
historyControlStr = concatStringsSep "\n"
historyControlStr = (concatStringsSep "\n"
(mapAttrsToList (n: v: "${n}=${v}") ({
HISTFILESIZE = toString cfg.historyFileSize;
HISTSIZE = toString cfg.historySize;
@ -190,7 +190,8 @@ in {
HISTCONTROL = concatStringsSep ":" cfg.historyControl;
} // optionalAttrs (cfg.historyIgnore != [ ]) {
HISTIGNORE = escapeShellArg (concatStringsSep ":" cfg.historyIgnore);
}));
}) ++ optional (cfg.historyFile != null)
''mkdir -p "$(dirname "$HISTFILE")"''));
in mkIf cfg.enable {
home.packages = [ cfg.package ];

View file

@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.bash = {
enable = true;
historyControl = [ "erasedups" ];
historyFile = "/home/hm-user/foo/bash/history";
};
nmt.script = ''
assertFileExists home-files/.bashrc
assertFileRegex home-files/.bashrc \
'^mkdir -p "\$(dirname "\$HISTFILE")"'
'';
};
}

View file

@ -2,4 +2,5 @@
bash-completion = ./completion.nix;
bash-logout = ./logout.nix;
bash-session-variables = ./session-variables.nix;
bash-history-control-with-file = ./bash-history-control-with-file.nix;
}