Skip to content

Commit 40d5f43

Browse files
committed
Fix: use buildCommand instead of postInstall for nix-support file
writeTextFile sets `buildCommand` in the derivation, which causes stdenv's genericBuild to skip the entire phase system — installPhase, postInstall, fixupPhase — none of them execute. The previous commit used postInstall which was silently ignored, leaving the wrapper output without nix-support/propagated-native-build-inputs. Append the file creation directly to buildCommand, which is the only code path the builder actually runs.
1 parent 711db81 commit 40d5f43

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

writers.nix

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@
3838
# 2. Write the $out/nix-support/propagated-native-build-inputs file
3939
#
4040
# Step 2 is critical: writeShellApplication uses writeTextFile internally,
41-
# which does NOT run stdenv.mkDerivation's fixupPhase. That fixupPhase is
42-
# what normally materializes the propagatedNativeBuildInputs derivation
41+
# which sets `buildCommand` in the derivation. When buildCommand is set,
42+
# stdenv's genericBuild skips the entire phase system — installPhase,
43+
# postInstall, fixupPhase — none of them run. The fixupPhase is what
44+
# normally materializes the propagatedNativeBuildInputs derivation
4345
# attribute into the $out/nix-support/propagated-native-build-inputs file
4446
# that setup.sh's findInputs reads at runtime. Without the file on disk,
4547
# setting the attribute alone has no effect — setup.sh never sees it.
4648
#
49+
# We therefore append the file creation directly to buildCommand, since
50+
# that is the only code path the builder actually executes.
51+
#
4752
# With the file in place, when stdenv's setup.sh processes the wrapper
4853
# from buildInputs or nativeBuildInputs, it:
4954
#
@@ -86,11 +91,10 @@
8691
propagatedNativeBuildInputs =
8792
(old.propagatedNativeBuildInputs or []) ++ allPropagated;
8893

89-
# writeShellApplication (via writeTextFile) does NOT run stdenv's
90-
# fixupPhase, so the propagatedNativeBuildInputs attribute is never
91-
# materialized into the nix-support/ file that setup.sh reads.
92-
# We create it explicitly in postInstall.
93-
postInstall = (old.postInstall or "") + ''
94+
# writeTextFile uses `buildCommand` which bypasses stdenv's entire
95+
# phase system — neither postInstall nor fixupPhase ever runs.
96+
# We must append our file creation directly to buildCommand.
97+
buildCommand = (old.buildCommand or "") + ''
9498
mkdir -p $out/nix-support
9599
echo "${propagatedPathsStr}" > $out/nix-support/propagated-native-build-inputs
96100
'';

0 commit comments

Comments
 (0)