From 9988224c2a1632ae9ee9ab0ba19b79e014d4f681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Sun, 10 Dec 2017 09:54:00 +0100 Subject: [PATCH 1/2] nixos/programs/bash: Let bash-completion lazy load scripts As described in detail here: https://github.com/NixOS/nixpkgs/issues/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`. fixes #32533 --- nixos/modules/programs/bash/bash.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 42973bef3fdd3c8aae8e9ade8db4c34f7308561a Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Sun, 10 Dec 2017 12:09:55 +0000 Subject: [PATCH 2/2] nixos/programs/bash: document that /etc/bash_completion.d is obsolete https://github.com/scop/bash-completion/blob/fbd52a5e31747beb4974da97b9d3ed4f6ceb7a61/bash_completion#L2070-L2078 --- nixos/modules/programs/bash/bash.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nixos/modules/programs/bash/bash.nix b/nixos/modules/programs/bash/bash.nix index 52d3780e045..1abdb4973a4 100644 --- a/nixos/modules/programs/bash/bash.nix +++ b/nixos/modules/programs/bash/bash.nix @@ -14,7 +14,10 @@ let bashCompletion = optionalString cfg.enableCompletion '' # Check whether we're running a version of Bash that has support for # programmable completion. If we do, enable all modules installed in - # the system (and user profile). + # the system and user profile in obsolete /etc/bash_completion.d/ + # directories. Bash loads completions in all + # $XDG_DATA_DIRS/share/bash-completion/completions/ + # on demand, so they do not need to be sourced here. if shopt -q progcomp &>/dev/null; then . "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" nullglobStatus=$(shopt -p nullglob)