From da2358353f1a4fa221909be98975e9eaf840381c Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 3 Dec 2025 16:25:26 +0900 Subject: [PATCH] nix: ensure argv0 is correct when generating completions --- nix/default.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index 6edceb8..918fce2 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -24,9 +24,12 @@ buildFunction { nativeBuildInputs = [ installShellFiles ]; postInstall = let - # "$out/bin/${mainProgram}" generate-completions --shell "${shell}" --command "${command}" > "$TMP/muscl.${shell}" - commands = lib.mapCartesianProduct ({ shell, command }: '' - COMPLETE=${shell} "$out/bin/${command}" > "$TMP/${command}.${shell}" + installShellCompletions = lib.mapCartesianProduct ({ shell, command }: '' + ( + export PATH="$out/bin:$PATH" + export COMPLETE="${shell}" + "${command}" > "$TMP/${command}.${shell}" + ) installShellCompletion "--${shell}" --cmd "${command}" "$TMP/${command}.${shell}" '') { shell = [ "bash" "zsh" "fish" ]; @@ -35,7 +38,9 @@ buildFunction { in '' ln -sr "$out/bin/muscl" "$out/bin/mysql-dbadm" ln -sr "$out/bin/muscl" "$out/bin/mysql-useradm" - '' + lib.concatStringsSep "\n" commands + '' + + ${lib.concatStringsSep "\n" installShellCompletions} + install -Dm444 assets/systemd/muscl.socket -t "$out/lib/systemd/system" install -Dm644 assets/systemd/muscl.service -t "$out/lib/systemd/system" substituteInPlace "$out/lib/systemd/system/muscl.service" \