File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change @@ -29,6 +29,18 @@ nix-build -o "$TEST_ROOT"/result dependencies.nix --post-build-hook "$pushToStor
2929export BUILD_HOOK_ONLY_OUT_PATHS=$( [ ! " $NIX_TESTS_CA_BY_DEFAULT " ])
3030nix-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+
3244clearStore
3345
3446# Ensure that the remote store contains both the runtime and build-time
You can’t perform that action at this time.
0 commit comments