mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
bash: add enableCompletion option
This commit is contained in:
parent
6b1e73adb1
commit
0495b41b4d
1 changed files with 28 additions and 7 deletions
|
@ -23,19 +23,21 @@ in
|
||||||
programs.bash.enable = mkOption {
|
programs.bash.enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = "Whether to configure bash as an interactive shell.";
|
||||||
Whether to configure bash as an interactive shell.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.bash.interactiveShellInit = mkOption {
|
programs.bash.interactiveShellInit = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
description = ''
|
description = "Shell script code called during interactive bash shell initialisation.";
|
||||||
Shell script code called during interactive bash shell initialisation.
|
|
||||||
'';
|
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
programs.bash.enableCompletion = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Enable bash completion for all interactive bash shells.";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -43,6 +45,11 @@ in
|
||||||
environment.systemPackages =
|
environment.systemPackages =
|
||||||
[ # Include bash package
|
[ # Include bash package
|
||||||
pkgs.bashInteractive
|
pkgs.bashInteractive
|
||||||
|
] ++ optional cfg.enableCompletion pkgs.bash-completion;
|
||||||
|
|
||||||
|
environment.pathsToLink =
|
||||||
|
[ "/etc/bash_completion.d"
|
||||||
|
"/share/bash-completion/completions"
|
||||||
];
|
];
|
||||||
|
|
||||||
environment.loginShell = mkDefault "${shell}/bin/bash -l";
|
environment.loginShell = mkDefault "${shell}/bin/bash -l";
|
||||||
|
@ -64,9 +71,23 @@ in
|
||||||
${config.environment.interactiveShellInit}
|
${config.environment.interactiveShellInit}
|
||||||
${cfg.interactiveShellInit}
|
${cfg.interactiveShellInit}
|
||||||
|
|
||||||
|
${optionalString cfg.enableCompletion ''
|
||||||
|
source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
|
||||||
|
|
||||||
|
nullglobStatus=$(shopt -p nullglob)
|
||||||
|
shopt -s nullglob
|
||||||
|
for p in $NIX_PROFILES; do
|
||||||
|
for m in "$p/etc/bash_completion.d/"* "$p/share/bash-completion/completions/"*; do
|
||||||
|
source $m
|
||||||
|
done
|
||||||
|
done
|
||||||
|
eval "$nullglobStatus"
|
||||||
|
unset nullglobStatus p m
|
||||||
|
''}
|
||||||
|
|
||||||
# Read system-wide modifications.
|
# Read system-wide modifications.
|
||||||
if test -f /etc/bash.local; then
|
if test -f /etc/bash.local; then
|
||||||
. /etc/bash.local
|
source /etc/bash.local
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue