From dd2ea746ce040136d557c5f3ae8e6f5c5e59fe8c Mon Sep 17 00:00:00 2001 From: Rahul Chalamala <22563365+rchalamala@users.noreply.github.com> Date: Sun, 5 Jul 2026 00:20:54 +0000 Subject: [PATCH] graphite-cli: fix darwin build The 1.8.6 bump (#527044) broke the package on darwin in two independent ways, unnoticed because the package is unfree and therefore never built by Hydra or ofborg: - postInstall generates shell completions by running $out/bin/gt, but gt tries to create ~/.config/graphite/aliases on startup and exits 1 with no output when HOME is not writable (as in nix builds, where HOME=/homeless-shelter). installShellCompletion then fails the build because the generated completion files are zero-size. Give the build a throwaway writable HOME. The Linux build is not affected because completions are generated through the buildFHSEnv wrapper, where / is a writable tmpfs. - dontFixup was only set on Linux, so on darwin fixupPhase ran strip -S on the binary. As the comment in this file already explains, the vercel/pkg virtual filesystem appended to the binary must not be modified; the stripped binary fails at runtime with "Pkg: Error reading from file." Skip fixup on all platforms. On Linux this is a no-op: the derivation is unchanged. Assisted-by: Devin (Ultra) Co-Authored-By: Rahul Chalamala <22563365+rchalamala@users.noreply.github.com> --- pkgs/by-name/gr/graphite-cli/package.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/gr/graphite-cli/package.nix b/pkgs/by-name/gr/graphite-cli/package.nix index c9fe9e7f899d..af2cc83f569d 100644 --- a/pkgs/by-name/gr/graphite-cli/package.nix +++ b/pkgs/by-name/gr/graphite-cli/package.nix @@ -76,9 +76,10 @@ let dontConfigure = true; dontBuild = true; - # On Linux the binary is wrapped with buildFHSEnv; completions are - # generated there. Here we only need to skip fixup to avoid patchelf/strip. - dontFixup = stdenv.hostPlatform.isLinux; + # Skip fixup on all platforms: strip discards the vercel/pkg virtual + # filesystem appended to the binary (see the comment below), leaving a + # binary that fails at runtime with "Pkg: Error reading from file." + dontFixup = true; installPhase = '' runHook preInstall @@ -86,7 +87,13 @@ let runHook postInstall ''; - postInstall = lib.optionalString stdenv.hostPlatform.isDarwin shellCompletions; + # gt tries to create ~/.config/graphite/aliases on startup and exits 1 + # with no output when HOME is not writable, which would leave the + # completion files empty. + postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' + export HOME=$(mktemp -d) + ${shellCompletions} + ''; }; in # The binary is built with vercel/pkg, which appends a virtual filesystem to