bash: add option bashrcExtra
This variable adds some extra flexibility in constructing the `~/.bashrc` file. Currently the option is hidden from public documentation since the option name is provisional.
This commit is contained in:
parent
8a2bf21cee
commit
78c308c835
|
@ -99,6 +99,17 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bashrcExtra = mkOption {
|
||||||
|
# Hide for now, may want to rename in the future.
|
||||||
|
visible = false;
|
||||||
|
default = "";
|
||||||
|
type = types.lines;
|
||||||
|
description = ''
|
||||||
|
Extra commands that should be added to
|
||||||
|
<filename>~/.bashrc</filename>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
initExtra = mkOption {
|
initExtra = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
|
@ -139,6 +150,25 @@ in
|
||||||
mapAttrsToList export (cfg.sessionVariables // globalEnvVars)
|
mapAttrsToList export (cfg.sessionVariables // globalEnvVars)
|
||||||
);
|
);
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
|
programs.bash.bashrcExtra = ''
|
||||||
|
# Commands that should be applied only for interactive shells.
|
||||||
|
if [[ -n $PS1 ]]; then
|
||||||
|
${export "HISTSIZE" cfg.historySize}
|
||||||
|
${export "HISTFILESIZE" cfg.historyFileSize}
|
||||||
|
${exportIfNonEmpty "HISTCONTROL" histControlStr}
|
||||||
|
${exportIfNonEmpty "HISTIGNORE" histIgnoreStr}
|
||||||
|
|
||||||
|
${shoptsStr}
|
||||||
|
|
||||||
|
${aliasesStr}
|
||||||
|
|
||||||
|
${cfg.initExtra}
|
||||||
|
|
||||||
|
${optionalString cfg.enableAutojump
|
||||||
|
". ${pkgs.autojump}/share/autojump/autojump.bash"}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
home.file.".bash_profile".text = ''
|
home.file.".bash_profile".text = ''
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
|
|
||||||
|
@ -160,22 +190,7 @@ in
|
||||||
home.file.".bashrc".text = ''
|
home.file.".bashrc".text = ''
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
|
|
||||||
# Skip if not running interactively.
|
${cfg.bashrcExtra}
|
||||||
[ -z "$PS1" ] && return
|
|
||||||
|
|
||||||
${export "HISTSIZE" cfg.historySize}
|
|
||||||
${export "HISTFILESIZE" cfg.historyFileSize}
|
|
||||||
${exportIfNonEmpty "HISTCONTROL" histControlStr}
|
|
||||||
${exportIfNonEmpty "HISTIGNORE" histIgnoreStr}
|
|
||||||
|
|
||||||
${shoptsStr}
|
|
||||||
|
|
||||||
${aliasesStr}
|
|
||||||
|
|
||||||
${cfg.initExtra}
|
|
||||||
|
|
||||||
${optionalString cfg.enableAutojump
|
|
||||||
". ${pkgs.autojump}/share/autojump/autojump.bash"}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.packages =
|
home.packages =
|
||||||
|
|
Loading…
Reference in a new issue