From f2b7d7b9c87c8cbf598d053771f25e16e6cdfe50 Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Thu, 16 Oct 2025 19:33:47 +0100 Subject: [PATCH] witness: provide completions for cross-compile Already skipped to keep compatible with cross but now also provide completions. --- pkgs/by-name/wi/witness/package.nix | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/wi/witness/package.nix b/pkgs/by-name/wi/witness/package.nix index 8e1930bf8c81..01a474354757 100644 --- a/pkgs/by-name/wi/witness/package.nix +++ b/pkgs/by-name/wi/witness/package.nix @@ -3,11 +3,14 @@ stdenv, buildGoModule, fetchFromGitHub, - installShellFiles, # testing testers, witness, + + installShellFiles, + + buildPackages, }: buildGoModule rec { @@ -42,12 +45,20 @@ buildGoModule rec { unset ldflags ''; - postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' - installShellCompletion --cmd witness \ - --bash <($out/bin/witness completion bash) \ - --fish <($out/bin/witness completion fish) \ - --zsh <($out/bin/witness completion zsh) - ''; + postInstall = + let + exe = + if stdenv.buildPlatform.canExecute stdenv.hostPlatform then + "$out/bin/witness" + else + lib.getExe buildPackages.witness; + in + '' + installShellCompletion --cmd witness \ + --bash <(${exe} completion bash) \ + --fish <(${exe} completion fish) \ + --zsh <(${exe} completion zsh) + ''; passthru.tests.version = testers.testVersion { package = witness;