1 { config, lib, pkgs, ... }:
4 cfg = config.programs.bash;
7 options.programs.bash.completion = {
8 enable = lib.mkEnableOption "Bash completion for all interactive bash shells" // {
12 package = lib.mkPackageOption pkgs "bash-completion" { };
16 (lib.mkRenamedOptionModule [ "programs" "bash" "enableCompletion" ] [ "programs" "bash" "completion" "enable" ])
19 config = lib.mkIf cfg.completion.enable {
20 programs.bash.promptPluginInit = ''
21 # Check whether we're running a version of Bash that has support for
22 # programmable completion. If we do, enable all modules installed in
23 # the system and user profile in obsolete /etc/bash_completion.d/
24 # directories. Bash loads completions in all
25 # $XDG_DATA_DIRS/bash-completion/completions/
26 # on demand, so they do not need to be sourced here.
27 if shopt -q progcomp &>/dev/null; then
28 . "${cfg.completion.package}/etc/profile.d/bash_completion.sh"
29 nullglobStatus=$(shopt -p nullglob)
31 for p in $NIX_PROFILES; do
32 for m in "$p/etc/bash_completion.d/"*; do
36 eval "$nullglobStatus"
37 unset nullglobStatus p m