apx: install shell completions

This commit is contained in:
John Garcia 2024-05-20 12:32:00 +01:00
parent a35fac798e
commit 45087e1666

View File

@ -4,6 +4,7 @@
fetchFromGitHub,
installShellFiles,
distrobox,
podman,
}:
buildGoModule rec {
@ -19,7 +20,8 @@ buildGoModule rec {
vendorHash = "sha256-hGi+M5RRUL2oyxFGVeR0sum93/CA+FGYy0m4vDmlXTc=";
nativeBuildInputs = [ installShellFiles ];
# podman needed for apx to not error when building shell completions
nativeBuildInputs = [ installShellFiles podman ];
ldflags = [ "-s" "-w" ];
@ -36,6 +38,15 @@ buildGoModule rec {
installManPage man/man1/*
install -Dm444 README.md -t $out/share/docs/apx
install -Dm444 COPYING.md $out/share/licenses/apx/LICENSE
# Create a temp writable home-dir so apx outputs completions without error
export HOME=$(mktemp -d)
# apx command now works (for completions)
# though complains "Error: no such file or directory"
installShellCompletion --cmd apx \
--bash <($out/bin/apx completion bash) \
--fish <($out/bin/apx completion fish) \
--zsh <($out/bin/apx completion zsh)
'';
meta = with lib; {