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.
This commit is contained in:
Olmo Kramer 2021-02-12 19:06:24 +01:00 committed by GitHub
parent 87e2ec341b
commit 1ee1d01daa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}