summary refs log tree commit diff
path: root/pkgs/development/tools/dyff
diff options
context:
space:
mode:
authorfigsoda <figsoda@pm.me>2021-10-29 09:10:36 -0400
committerfigsoda <figsoda@pm.me>2021-10-29 09:11:34 -0400
commit17ca0b4d1dbb5ca2b472ad1e8fd4fa300e2daec3 (patch)
treed35d0bb8d72952a955d7ac66b033685ad5292454 /pkgs/development/tools/dyff
parent7de4bd4e444c70ba9cbb37620fe629ce334237cb (diff)
dyff: fix version output, install shell completions
Diffstat (limited to 'pkgs/development/tools/dyff')
-rw-r--r--pkgs/development/tools/dyff/default.nix23
1 files changed, 22 insertions, 1 deletions
diff --git a/pkgs/development/tools/dyff/default.nix b/pkgs/development/tools/dyff/default.nix
index d13a7a91ec42f..eab35b69585c0 100644
--- a/pkgs/development/tools/dyff/default.nix
+++ b/pkgs/development/tools/dyff/default.nix
@@ -1,4 +1,4 @@
-{ lib, buildGoModule, fetchFromGitHub}:
+{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
 
 buildGoModule rec {
   pname = "dyff";
@@ -19,6 +19,27 @@ buildGoModule rec {
     "internal/cmd"
   ];
 
+  nativeBuildInputs = [ installShellFiles ];
+
+  # test fails with the injected version
+  postPatch = ''
+    substituteInPlace internal/cmd/cmds_test.go \
+      --replace "version (development)" ${version}
+  '';
+
+  ldflags = [
+    "-s"
+    "-w"
+    "-X=github.com/homeport/dyff/internal/cmd.version=${version}"
+  ];
+
+  postInstall = ''
+    installShellCompletion --cmd dyff \
+      --bash <($out/bin/dyff completion bash) \
+      --fish <($out/bin/dyff completion fish) \
+      --zsh <($out/bin/dyff completion zsh)
+  '';
+
   meta = with lib; {
     description = "A diff tool for YAML files, and sometimes JSON";
     longDescription = ''