From 1ee1d01daa19b3a6d16b5fb680c31a2bc110ce24 Mon Sep 17 00:00:00 2001 From: Olmo Kramer Date: Fri, 12 Feb 2021 19:06:24 +0100 Subject: [PATCH] bash: don't unconditionally set HISTFILE variable (#1621) The bash module always assigns a value to HISTFILE in the bashrc, even when no value is explicitly set. This makes it impossible to tell bash to use a different HISTFILE by setting the HISTFILE environment variable HISTFILE=/tmp/bash_history bash This changes the default value of programs.bash.historyFile to null, and only writes the HISTFILE=... line to the bashrc if it is changed to something else. --- modules/programs/bash.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix index 6338f5e4a..60d1358d3 100644 --- a/modules/programs/bash.nix +++ b/modules/programs/bash.nix @@ -30,8 +30,8 @@ in }; historyFile = mkOption { - type = types.str; - default = "$HOME/.bash_history"; + type = types.nullOr types.str; + default = null; description = "Location of the bash history file."; }; @@ -157,10 +157,12 @@ in historyControlStr = concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") ( { - HISTFILE = "\"${cfg.historyFile}\""; HISTFILESIZE = toString cfg.historyFileSize; HISTSIZE = toString cfg.historySize; } + // optionalAttrs (cfg.historyFile != null) { + HISTFILE = "\"${cfg.historyFile}\""; + } // optionalAttrs (cfg.historyControl != []) { HISTCONTROL = concatStringsSep ":" cfg.historyControl; }