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:
parent
daf04c5950
commit
26651d1bf5
3 changed files with 24 additions and 2 deletions
|
@ -180,7 +180,7 @@ in {
|
||||||
|
|
||||||
sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;
|
sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;
|
||||||
|
|
||||||
historyControlStr = concatStringsSep "\n"
|
historyControlStr = (concatStringsSep "\n"
|
||||||
(mapAttrsToList (n: v: "${n}=${v}") ({
|
(mapAttrsToList (n: v: "${n}=${v}") ({
|
||||||
HISTFILESIZE = toString cfg.historyFileSize;
|
HISTFILESIZE = toString cfg.historyFileSize;
|
||||||
HISTSIZE = toString cfg.historySize;
|
HISTSIZE = toString cfg.historySize;
|
||||||
|
@ -190,7 +190,8 @@ in {
|
||||||
HISTCONTROL = concatStringsSep ":" cfg.historyControl;
|
HISTCONTROL = concatStringsSep ":" cfg.historyControl;
|
||||||
} // optionalAttrs (cfg.historyIgnore != [ ]) {
|
} // optionalAttrs (cfg.historyIgnore != [ ]) {
|
||||||
HISTIGNORE = escapeShellArg (concatStringsSep ":" cfg.historyIgnore);
|
HISTIGNORE = escapeShellArg (concatStringsSep ":" cfg.historyIgnore);
|
||||||
}));
|
}) ++ optional (cfg.historyFile != null)
|
||||||
|
''mkdir -p "$(dirname "$HISTFILE")"''));
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
|
|
@ -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")"'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,4 +2,5 @@
|
||||||
bash-completion = ./completion.nix;
|
bash-completion = ./completion.nix;
|
||||||
bash-logout = ./logout.nix;
|
bash-logout = ./logout.nix;
|
||||||
bash-session-variables = ./session-variables.nix;
|
bash-session-variables = ./session-variables.nix;
|
||||||
|
bash-history-control-with-file = ./bash-history-control-with-file.nix;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue