fix(nix): bake shell completions into default package (#1229)
The default package now includes fish, bash, and zsh completions at standard paths. This means users only need to install the default package to get both the binary and completions. The separate completion packages are kept for backwards compatibility but now simply symlink to the default package. Standard completion paths: - share/fish/vendor_completions.d/bd.fish - share/bash-completion/completions/bd - share/zsh/site-functions/_bd
This commit is contained in:
committed by
GitHub
parent
bb4549abdd
commit
3daec76ac9
32
flake.nix
32
flake.nix
@@ -23,25 +23,49 @@
|
|||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
bd = pkgs.callPackage ./default.nix { inherit pkgs self; };
|
bdBase = pkgs.callPackage ./default.nix { inherit pkgs self; };
|
||||||
|
# Wrap the base package with shell completions baked in
|
||||||
|
bd = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "beads";
|
||||||
|
version = bdBase.version;
|
||||||
|
|
||||||
|
phases = [ "installPhase" ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp ${bdBase}/bin/bd $out/bin/bd
|
||||||
|
|
||||||
|
# Generate shell completions
|
||||||
|
mkdir -p $out/share/fish/vendor_completions.d
|
||||||
|
mkdir -p $out/share/bash-completion/completions
|
||||||
|
mkdir -p $out/share/zsh/site-functions
|
||||||
|
|
||||||
|
$out/bin/bd completion fish > $out/share/fish/vendor_completions.d/bd.fish
|
||||||
|
$out/bin/bd completion bash > $out/share/bash-completion/completions/bd
|
||||||
|
$out/bin/bd completion zsh > $out/share/zsh/site-functions/_bd
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = bdBase.meta;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
default = bd;
|
default = bd;
|
||||||
|
|
||||||
|
# Keep separate completion packages for users who only want specific shells
|
||||||
fish-completions = pkgs.runCommand "bd-fish-completions" { } ''
|
fish-completions = pkgs.runCommand "bd-fish-completions" { } ''
|
||||||
mkdir -p $out/share/fish/vendor_completions.d
|
mkdir -p $out/share/fish/vendor_completions.d
|
||||||
${bd}/bin/bd completion fish > $out/share/fish/vendor_completions.d/bd.fish
|
ln -s ${bd}/share/fish/vendor_completions.d/bd.fish $out/share/fish/vendor_completions.d/bd.fish
|
||||||
'';
|
'';
|
||||||
|
|
||||||
bash-completions = pkgs.runCommand "bd-bash-completions" { } ''
|
bash-completions = pkgs.runCommand "bd-bash-completions" { } ''
|
||||||
mkdir -p $out/share/bash-completion/completions
|
mkdir -p $out/share/bash-completion/completions
|
||||||
${bd}/bin/bd completion bash > $out/share/bash-completion/completions/bd
|
ln -s ${bd}/share/bash-completion/completions/bd $out/share/bash-completion/completions/bd
|
||||||
'';
|
'';
|
||||||
|
|
||||||
zsh-completions = pkgs.runCommand "bd-zsh-completions" { } ''
|
zsh-completions = pkgs.runCommand "bd-zsh-completions" { } ''
|
||||||
mkdir -p $out/share/zsh/site-functions
|
mkdir -p $out/share/zsh/site-functions
|
||||||
${bd}/bin/bd completion zsh > $out/share/zsh/site-functions/_bd
|
ln -s ${bd}/share/zsh/site-functions/_bd $out/share/zsh/site-functions/_bd
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user