Issue description
Opening up a new issue, as the last one, #22648, is closed.
bash-completion is designed to lazy load completions via __completion_loader. NixOS's generated /etc/bashrc however eagerly sources everything in $NIX_PROFILES/bash-completion/completions/* on startup (bash.nix).
This usually isn't a big problem when bash-completion isn't installed into a profile, since the big bulk of completion scripts bash-completion ships with will be correctly lazy loaded, leaving only a small amount of scripts being sourced on startup.
This however breaks when installing bash-completion as everything will be sourced on startup.
The fix
I believe the fix is simply not sourcing $NIX_PROFILES/bash-completion/completions/* via /etc/bashrc, leaving it fully up to bash-completion lazely load the scripts (it should look in its own nix store path and in ~/.nix-profile/share via $XDG_DATA_DIRS (ref).
Though I might've missed something of course so ccing @peti as he's the author of e627d30 and might know if there's any pitfalls in not sourcing on startup.
Steps to reproduce
- enable
programs.bash.enableCompletion
- install
bash-completion, either via. systemPackages or nix-env -iA nixos.bash-completion
- start a new interactive bash shell
Technical details
- system:
"x86_64-linux"
- host os:
Linux 4.9.65, NixOS, 18.03.git.4cbbecc (Impala)
- multi-user?:
yes
- sandbox:
yes
- version:
nix-env (Nix) 1.11.15
- channels(hed):
""
- channels(root):
"nixos-17.09.1462.07ca7b64d2"
- nixpkgs:
/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
Issue description
Opening up a new issue, as the last one, #22648, is closed.
bash-completionis designed to lazy load completions via __completion_loader. NixOS's generated/etc/bashrchowever eagerly sources everything in$NIX_PROFILES/bash-completion/completions/*on startup (bash.nix).This usually isn't a big problem when
bash-completionisn't installed into a profile, since the big bulk of completion scriptsbash-completionships with will be correctly lazy loaded, leaving only a small amount of scripts being sourced on startup.This however breaks when installing
bash-completionas everything will be sourced on startup.The fix
I believe the fix is simply not sourcing
$NIX_PROFILES/bash-completion/completions/*via/etc/bashrc, leaving it fully up tobash-completionlazely load the scripts (it should look in its own nix store path and in~/.nix-profile/sharevia$XDG_DATA_DIRS(ref).Though I might've missed something of course so ccing @peti as he's the author of e627d30 and might know if there's any pitfalls in not sourcing on startup.
Steps to reproduce
programs.bash.enableCompletionbash-completion, either via.systemPackagesornix-env -iA nixos.bash-completionTechnical details
"x86_64-linux"Linux 4.9.65, NixOS, 18.03.git.4cbbecc (Impala)yesyesnix-env (Nix) 1.11.15"""nixos-17.09.1462.07ca7b64d2"/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs