Install shell completions in derivation

This commit is contained in:
adisbladis 2022-06-13 23:31:18 +08:00
parent ab0d607923
commit 363017e3f3

View file

@ -1,4 +1,4 @@
{ buildGoApplication, go, nix, lib, makeWrapper, nix-prefetch-git }: { stdenv, buildGoApplication, go, nix, lib, makeWrapper, installShellFiles }:
buildGoApplication { buildGoApplication {
inherit go; inherit go;
@ -18,9 +18,15 @@ buildGoApplication {
subPackages = [ "." ]; subPackages = [ "." ];
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper installShellFiles ];
postInstall = '' postInstall = lib.optionalString (stdenv.hostPlatform == stdenv.targetPlatform) ''
$out/bin/gomod2nix completion bash > gomod2nix.bash
$out/bin/gomod2nix completion fish > gomod2nix.fish
$out/bin/gomod2nix completion zsh > _gomod2nix
installShellCompletion gomod2nix.{bash,fish} _gomod2nix
'' + ''
wrapProgram $out/bin/gomod2nix --prefix PATH : ${lib.makeBinPath [ go ]} wrapProgram $out/bin/gomod2nix --prefix PATH : ${lib.makeBinPath [ go ]}
''; '';
} }