1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2025-01-30 21:05:02 +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
parent daf04c5950
commit 26651d1bf5
No known key found for this signature in database
GPG key ID: B68746238E59B548
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;
}