You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Tested the fix out now, and it does seem to work, (completion scripts are being picked up from /run/current-system/sw/share/bash-completion/completions and ~/.nix-profile/share/bash-completion/completions), will make PR.
diff --git a/nixos/modules/programs/bash/bash.nix b/nixos/modules/programs/bash/bash.nix
index ef1acdfe66e..52d3780e045 100644
--- a/nixos/modules/programs/bash/bash.nix+++ b/nixos/modules/programs/bash/bash.nix@@ -20,7 +20,7 @@ let
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+ for m in "$p/etc/bash_completion.d/"*; do
. $m
done
done
As described in detail here: NixOS/nixpkgs#32533
bash will load completion scripts in $p/share/bash-completion/completions/ on
startup instead of letting bash-completion do it's lazy loading. Bash startup
will then slow down (very noticeable when bash-completion is installed in a
profile).
This commit leaves loading of scripts in the hands of bash-completion,
improving startup time for everyone using `enableCompletion`.
FixesLnL7#101
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 scriptsbash-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 tobash-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
programs.bash.enableCompletion
bash-completion
, either via.systemPackages
ornix-env -iA nixos.bash-completion
Technical details
"x86_64-linux"
Linux 4.9.65, NixOS, 18.03.git.4cbbecc (Impala)
yes
yes
nix-env (Nix) 1.11.15
""
"nixos-17.09.1462.07ca7b64d2"
/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
The text was updated successfully, but these errors were encountered: