summaryrefslogtreecommitdiff
path: root/modules/programs/bash
diff options
context:
space:
mode:
Diffstat (limited to 'modules/programs/bash')
-rw-r--r--modules/programs/bash/default.nix37
1 files changed, 21 insertions, 16 deletions
diff --git a/modules/programs/bash/default.nix b/modules/programs/bash/default.nix
index 61f82e0..2518c9c 100644
--- a/modules/programs/bash/default.nix
+++ b/modules/programs/bash/default.nix
@@ -7,28 +7,36 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "bash" "enableCompletion" ] [ "programs" "bash" "completion" "enable" ])
+ ];
+
options = {
programs.bash.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Whether to configure bash as an interactive shell.";
+ description = "Whether to configure bash as an interactive shell.";
};
programs.bash.interactiveShellInit = mkOption {
default = "";
- description = lib.mdDoc "Shell script code called during interactive bash shell initialisation.";
+ description = "Shell script code called during interactive bash shell initialisation.";
type = types.lines;
};
- programs.bash.enableCompletion = mkOption {
- type = types.bool;
- default = false;
- description = lib.mdDoc ''
- Enable bash completion for all interactive bash shells.
+ programs.bash.completion = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Enable bash completion for all interactive bash shells.
- NOTE. This doesn't work with bash 3.2, which is the default on macOS.
- '';
+ NOTE: This doesn't work with bash 3.2, which is installed by default on macOS by Apple.
+ '';
+ };
+
+ package = mkPackageOption pkgs "bash-completion" { };
};
};
@@ -38,9 +46,9 @@ in
environment.systemPackages =
[ # Include bash package
pkgs.bashInteractive
- ] ++ optional cfg.enableCompletion pkgs.bash-completion;
+ ] ++ optional cfg.completion.enable cfg.completion.package;
- environment.pathsToLink =
+ environment.pathsToLink = optionals cfg.completion.enable
[ "/etc/bash_completion.d"
"/share/bash-completion/completions"
];
@@ -55,9 +63,6 @@ in
if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
__ETC_BASHRC_SOURCED=1
- # Don't execute this file when running in a pure nix-shell.
- if [ "$IN_NIX_SHELL" = "pure" ]; then return; fi
-
if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then
. ${config.system.build.setEnvironment}
fi
@@ -73,9 +78,9 @@ in
${config.environment.interactiveShellInit}
${cfg.interactiveShellInit}
- ${optionalString cfg.enableCompletion ''
+ ${optionalString cfg.completion.enable ''
if [ "$TERM" != "dumb" ]; then
- source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
+ source "${cfg.completion.package}/etc/profile.d/bash_completion.sh"
nullglobStatus=$(shopt -p nullglob)
shopt -s nullglob