From 363017e3f31cdaa3807899f03488088d8a314652 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 13 Jun 2022 23:31:18 +0800 Subject: [PATCH] Install shell completions in derivation --- default.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index efedc76..636bca8 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ buildGoApplication, go, nix, lib, makeWrapper, nix-prefetch-git }: +{ stdenv, buildGoApplication, go, nix, lib, makeWrapper, installShellFiles }: buildGoApplication { inherit go; @@ -18,9 +18,15 @@ buildGoApplication { 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 ]} ''; + }