bash: Make HISTFILESIZE and HISTSIZE nullable (#6443)

This commit is contained in:
André Schröder 2025-02-13 15:58:45 +01:00 committed by GitHub
parent a70d788923
commit 22b418c13f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -51,7 +51,7 @@ in {
};
historySize = mkOption {
type = types.int;
type = types.nullOr types.int;
default = 10000;
description = "Number of history lines to keep in memory.";
};
@ -63,7 +63,7 @@ in {
};
historyFileSize = mkOption {
type = types.int;
type = types.nullOr types.int;
default = 100000;
description = "Number of history lines to keep on file.";
};
@ -181,16 +181,18 @@ in {
sessionVarsStr = config.lib.shell.exportAll cfg.sessionVariables;
historyControlStr = (concatStringsSep "\n"
(mapAttrsToList (n: v: "${n}=${v}") ({
HISTFILESIZE = toString cfg.historyFileSize;
HISTSIZE = toString cfg.historySize;
} // optionalAttrs (cfg.historyFile != null) {
HISTFILE = ''"${cfg.historyFile}"'';
} // optionalAttrs (cfg.historyControl != [ ]) {
HISTCONTROL = concatStringsSep ":" cfg.historyControl;
} // optionalAttrs (cfg.historyIgnore != [ ]) {
HISTIGNORE = escapeShellArg (concatStringsSep ":" cfg.historyIgnore);
}) ++ optional (cfg.historyFile != null)
(mapAttrsToList (n: v: "${n}=${v}")
(optionalAttrs (cfg.historyFileSize != null) {
HISTFILESIZE = toString cfg.historyFileSize;
} // optionalAttrs (cfg.historySize != null) {
HISTSIZE = toString cfg.historySize;
} // optionalAttrs (cfg.historyFile != null) {
HISTFILE = ''"${cfg.historyFile}"'';
} // optionalAttrs (cfg.historyControl != [ ]) {
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 ];