mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 11:36:03 +01:00
Merge pull request #14409 from NixOS/backport-14289-to-2.32-maintenance
[Backport 2.32-maintenance] Fix issue #14287
This commit is contained in:
commit
758dacacf4
3 changed files with 33 additions and 1 deletions
|
|
@ -860,7 +860,15 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
{
|
{
|
||||||
builder.reset();
|
builder.reset();
|
||||||
StorePathSet outputPaths;
|
StorePathSet outputPaths;
|
||||||
for (auto & [_, output] : builtOutputs) {
|
/* In the check case we install no store objects, and so
|
||||||
|
`builtOutputs` is empty. However, per issue #14287, there is
|
||||||
|
an expectation that the post-build hook is still executed.
|
||||||
|
(This is useful for e.g. logging successful deterministic rebuilds.)
|
||||||
|
|
||||||
|
In order to make that work, in the check case just load the
|
||||||
|
(preexisting) infos from scratch, rather than relying on what
|
||||||
|
`DerivationBuilder` returned to us. */
|
||||||
|
for (auto & [_, output] : buildMode == bmCheck ? checkPathValidity(initialOutputs).second : builtOutputs) {
|
||||||
// for sake of `bmRepair`
|
// for sake of `bmRepair`
|
||||||
worker.markContentsGood(output.outPath);
|
worker.markContentsGood(output.outPath);
|
||||||
outputPaths.insert(output.outPath);
|
outputPaths.insert(output.outPath);
|
||||||
|
|
|
||||||
12
tests/functional/build-hook-list-paths.sh
Executable file
12
tests/functional/build-hook-list-paths.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
[ -n "$OUT_PATHS" ]
|
||||||
|
[ -n "$DRV_PATH" ]
|
||||||
|
[ -n "$HOOK_DEST" ]
|
||||||
|
|
||||||
|
for o in $OUT_PATHS; do
|
||||||
|
echo "$o" >> "$HOOK_DEST"
|
||||||
|
done
|
||||||
|
|
@ -29,6 +29,18 @@ nix-build -o "$TEST_ROOT"/result dependencies.nix --post-build-hook "$pushToStor
|
||||||
export BUILD_HOOK_ONLY_OUT_PATHS=$([ ! "$NIX_TESTS_CA_BY_DEFAULT" ])
|
export BUILD_HOOK_ONLY_OUT_PATHS=$([ ! "$NIX_TESTS_CA_BY_DEFAULT" ])
|
||||||
nix-build -o "$TEST_ROOT"/result-mult multiple-outputs.nix -A a.first --post-build-hook "$pushToStore"
|
nix-build -o "$TEST_ROOT"/result-mult multiple-outputs.nix -A a.first --post-build-hook "$pushToStore"
|
||||||
|
|
||||||
|
if isDaemonNewer "2.33.0pre20251029"; then
|
||||||
|
# Regression test for issue #14287: `--check` should re-run post build
|
||||||
|
# hook, even though nothing is getting newly registered.
|
||||||
|
export HOOK_DEST=$TEST_ROOT/listing
|
||||||
|
# Needed so the hook will get the above environment variable.
|
||||||
|
restartDaemon
|
||||||
|
nix-build -o "$TEST_ROOT"/result-mult multiple-outputs.nix --check -A a.first --post-build-hook "$PWD/build-hook-list-paths.sh"
|
||||||
|
grepQuiet a-first "$HOOK_DEST"
|
||||||
|
grepQuiet a-second "$HOOK_DEST"
|
||||||
|
unset HOOK_DEST
|
||||||
|
fi
|
||||||
|
|
||||||
clearStore
|
clearStore
|
||||||
|
|
||||||
# Ensure that the remote store contains both the runtime and build-time
|
# Ensure that the remote store contains both the runtime and build-time
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue