From fe8be036fd510a8753401646a93ebf1a1313da40 Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Mon, 17 Feb 2025 18:32:59 -0700 Subject: [PATCH] Enable shell completion of `ucm` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `postInstall` was never getting executed (because `installPhase` was missing `runHook postInstall`). So I added the missing `runHooks`. However, that errored, as the `--runtime-path` (set by the wrapper) and `--*-completion-script` options don’t work together. To avoid that, I generated the completions for the wrapped command from the unwrapped command. --- nix/ucm.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nix/ucm.nix b/nix/ucm.nix index 7cfad5a..9beff2c 100644 --- a/nix/ucm.nix +++ b/nix/ucm.nix @@ -69,6 +69,7 @@ inherit (srcArgs) sha256; }; + unison = "$out/unison/unison"; ucm = "$out/bin/ucm"; in stdenv.mkDerivation rec { @@ -94,23 +95,27 @@ in binPath = lib.makeBinPath buildInputs; installPhase = '' + runHook preInstall + mkdir -p $out/{bin,lib} mv runtime $out/lib/runtime mv unison $out/unison mv ui $out/ui - makeWrapper $out/unison/unison ${ucm} \ + makeWrapper ${unison} ${ucm} \ --prefix PATH : ${binPath} \ --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [libb2 openssl curl]} \ --add-flags "--runtime-path $out/lib/runtime/bin/unison-runtime" \ --set-default UCM_WEB_UI "$out/ui" + + runHook postInstall ''; postInstall = '' installShellCompletion --cmd ucm \ - --bash <(${ucm} --bash-completion-script ${ucm}) \ - --fish <(${ucm} --fish-completion-script ${ucm}) \ - --zsh <(${ucm} --zsh-completion-script ${ucm}) + --bash <(${unison} --bash-completion-script ${ucm}) \ + --fish <(${unison} --fish-completion-script ${ucm}) \ + --zsh <(${unison} --zsh-completion-script ${ucm}) ''; installCheckPhase = ''