From 22b418c13fb0be43f4bc5c185f323a3237028594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Schr=C3=B6der?= Date: Thu, 13 Feb 2025 15:58:45 +0100 Subject: [PATCH] bash: Make HISTFILESIZE and HISTSIZE nullable (#6443) --- modules/programs/bash.nix | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 8356d8a0..0c99da3e 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -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 ];