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>
This commit is contained in:
committed by
Devin AI
parent
7d5d19274b
commit
dd2ea746ce
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user