bash: use shell library
This commit is contained in:
parent
58a629b02e
commit
026375da49
|
@ -131,12 +131,6 @@ in
|
||||||
map (v: "shopt -s ${v}") cfg.shellOptions
|
map (v: "shopt -s ${v}") cfg.shellOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
export = n: v: "export ${n}=\"${toString v}\"";
|
|
||||||
setIfNonEmpty = n: v: optionalString (v != "") "${n}=${toString v}";
|
|
||||||
|
|
||||||
histControlStr = concatStringsSep ":" cfg.historyControl;
|
|
||||||
histIgnoreStr = concatStringsSep ":" cfg.historyIgnore;
|
|
||||||
|
|
||||||
# If Bash is the session variable setter then this is the
|
# If Bash is the session variable setter then this is the
|
||||||
# attribute set of global session variables, otherwise it is an
|
# attribute set of global session variables, otherwise it is an
|
||||||
# empty set.
|
# empty set.
|
||||||
|
@ -145,17 +139,27 @@ in
|
||||||
(config.home.sessionVariableSetter == "bash")
|
(config.home.sessionVariableSetter == "bash")
|
||||||
config.home.sessionVariables;
|
config.home.sessionVariables;
|
||||||
|
|
||||||
envVarsStr = concatStringsSep "\n" (
|
envVarsStr =
|
||||||
mapAttrsToList export (cfg.sessionVariables // globalEnvVars)
|
config.lib.shell.exportAll (cfg.sessionVariables // globalEnvVars);
|
||||||
);
|
|
||||||
|
historyControlStr =
|
||||||
|
concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") (
|
||||||
|
{
|
||||||
|
HISTSIZE = toString cfg.historySize;
|
||||||
|
HISTFILESIZE = toString cfg.historyFileSize;
|
||||||
|
}
|
||||||
|
// optionalAttrs (cfg.historyControl != []) {
|
||||||
|
HISTCONTROL = concatStringsSep ":" cfg.historyControl;
|
||||||
|
}
|
||||||
|
// optionalAttrs (cfg.historyIgnore != []) {
|
||||||
|
HISTIGNORE = concatStringsSep ":" cfg.historyIgnore;
|
||||||
|
}
|
||||||
|
));
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
programs.bash.bashrcExtra = ''
|
programs.bash.bashrcExtra = ''
|
||||||
# Commands that should be applied only for interactive shells.
|
# Commands that should be applied only for interactive shells.
|
||||||
if [[ -n $PS1 ]]; then
|
if [[ -n $PS1 ]]; then
|
||||||
HISTSIZE=${toString cfg.historySize}
|
${historyControlStr}
|
||||||
HISTFILESIZE=${toString cfg.historyFileSize}
|
|
||||||
${setIfNonEmpty "HISTCONTROL" histControlStr}
|
|
||||||
${setIfNonEmpty "HISTIGNORE" histIgnoreStr}
|
|
||||||
|
|
||||||
${shoptsStr}
|
${shoptsStr}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue