diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix
index 60d1358d3..bcaab88e9 100644
--- a/modules/programs/bash.nix
+++ b/modules/programs/bash.nix
@@ -111,17 +111,6 @@ 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
- ~/.bashrc.
- '';
- };
-
initExtra = mkOption {
default = "";
type = types.lines;
@@ -131,6 +120,15 @@ in
'';
};
+ bashrcExtra = mkOption {
+ default = "";
+ type = types.lines;
+ description = ''
+ Extra commands that should be placed in ~/.bashrc.
+ Note that these commands will be run even in non-interactive shells.
+ '';
+ };
+
logoutExtra = mkOption {
default = "";
type = types.lines;
@@ -171,19 +169,6 @@ in
}
));
in mkIf cfg.enable {
- programs.bash.bashrcExtra = ''
- # Commands that should be applied only for interactive shells.
- if [[ $- == *i* ]]; then
- ${historyControlStr}
-
- ${shoptsStr}
-
- ${aliasesStr}
-
- ${cfg.initExtra}
- fi
- '';
-
home.file.".bash_profile".text = ''
# -*- mode: sh -*-
@@ -208,6 +193,17 @@ in
# -*- mode: sh -*-
${cfg.bashrcExtra}
+
+ # Commands that should be applied only for interactive shells.
+ [[ $- == *i* ]] || return
+
+ ${historyControlStr}
+
+ ${shoptsStr}
+
+ ${aliasesStr}
+
+ ${cfg.initExtra}
'';
home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") {