nix-bash-completions: lazy load aware install
`bash-completion` lazy loads completion scripts by looking up the command name in the completion directory. As such we need to create a symlink for every nix command. The problem had been masked by nixos sourcing all completion scripts on startup.
This commit is contained in:
parent
166536e152
commit
f79d69113e
@ -1,19 +1,29 @@
|
|||||||
{ stdenv, fetchFromGitHub }:
|
{ stdenv, fetchFromGitHub }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
version = "0.6";
|
version = "0.6.1";
|
||||||
name = "nix-bash-completions-${version}";
|
name = "nix-bash-completions-${version}";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "hedning";
|
owner = "hedning";
|
||||||
repo = "nix-bash-completions";
|
repo = "nix-bash-completions";
|
||||||
rev = "v${version}";
|
rev = "v${version}";
|
||||||
sha256 = "093rla6wwx51fclh7xm8qlssx70hj0fj23r59qalaaxf7fdzg2hf";
|
sha256 = "10nzdn249f0cw6adgpbpg4x90ysvxm7vs9jjbbwynfh9kngijp64";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# To enable lazy loading via. bash-completion we need a symlink to the script
|
||||||
|
# from every command name.
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/share/bash-completion/completions
|
commands=$(
|
||||||
cp _nix $out/share/bash-completion/completions
|
function complete() { shift 2; echo "$@"; }
|
||||||
|
shopt -s extglob
|
||||||
|
source _nix
|
||||||
|
)
|
||||||
|
install -Dm444 -t $out/share/bash-completion/completions _nix
|
||||||
|
cd $out/share/bash-completion/completions
|
||||||
|
for c in $commands; do
|
||||||
|
ln -s _nix $c
|
||||||
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user