Skip to content

Commit bac41d6

Browse files
authored
Merge pull request #14289 from obsidiansystems/fix-14287
Fix issue #14287
2 parents 194c21f + de19279 commit bac41d6

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/libstore/build/derivation-building-goal.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,15 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
677677
{
678678
builder.reset();
679679
StorePathSet outputPaths;
680-
for (auto & [_, output] : builtOutputs) {
680+
/* In the check case we install no store objects, and so
681+
`builtOutputs` is empty. However, per issue #14287, there is
682+
an expectation that the post-build hook is still executed.
683+
(This is useful for e.g. logging successful deterministic rebuilds.)
684+
685+
In order to make that work, in the check case just load the
686+
(preexisting) infos from scratch, rather than relying on what
687+
`DerivationBuilder` returned to us. */
688+
for (auto & [_, output] : buildMode == bmCheck ? checkPathValidity(initialOutputs).second : builtOutputs) {
681689
// for sake of `bmRepair`
682690
worker.markContentsGood(output.outPath);
683691
outputPaths.insert(output.outPath);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
set -x
4+
set -e
5+
6+
[ -n "$OUT_PATHS" ]
7+
[ -n "$DRV_PATH" ]
8+
[ -n "$HOOK_DEST" ]
9+
10+
for o in $OUT_PATHS; do
11+
echo "$o" >> "$HOOK_DEST"
12+
done

tests/functional/post-hook.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ nix-build -o "$TEST_ROOT"/result dependencies.nix --post-build-hook "$pushToStor
2929
export BUILD_HOOK_ONLY_OUT_PATHS=$([ ! "$NIX_TESTS_CA_BY_DEFAULT" ])
3030
nix-build -o "$TEST_ROOT"/result-mult multiple-outputs.nix -A a.first --post-build-hook "$pushToStore"
3131

32+
if isDaemonNewer "2.33.0pre20251029"; then
33+
# Regression test for issue #14287: `--check` should re-run post build
34+
# hook, even though nothing is getting newly registered.
35+
export HOOK_DEST=$TEST_ROOT/listing
36+
# Needed so the hook will get the above environment variable.
37+
restartDaemon
38+
nix-build -o "$TEST_ROOT"/result-mult multiple-outputs.nix --check -A a.first --post-build-hook "$PWD/build-hook-list-paths.sh"
39+
grepQuiet a-first "$HOOK_DEST"
40+
grepQuiet a-second "$HOOK_DEST"
41+
unset HOOK_DEST
42+
fi
43+
3244
clearStore
3345

3446
# Ensure that the remote store contains both the runtime and build-time

0 commit comments

Comments
 (0)