@@ -127,6 +127,8 @@ static void runPostBuildHook(
127
127
produced using a substitute. So we have to build instead. */
128
128
Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution ()
129
129
{
130
+ std::map<std::string, InitialOutput> initialOutputs;
131
+
130
132
/* Recheck at goal start. In particular, whereas before we were
131
133
given this information by the downstream goal, that cannot happen
132
134
anymore if the downstream goal only cares about one output, but
@@ -150,7 +152,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
150
152
std::move (v),
151
153
});
152
154
}
153
- checkPathValidity ();
155
+ checkPathValidity (initialOutputs );
154
156
155
157
Goals waitees;
156
158
@@ -531,7 +533,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
531
533
omitted, but that would be less efficient.) Note that since we
532
534
now hold the locks on the output paths, no other process can
533
535
build this derivation, so no further checks are necessary. */
534
- auto [allValid, validOutputs] = checkPathValidity ();
536
+ auto [allValid, validOutputs] = checkPathValidity (initialOutputs );
535
537
536
538
if (buildMode != bmCheck && allValid) {
537
539
debug (" skipping build of derivation '%s', someone beat us to it" , worker.store .printStorePath (drvPath));
@@ -559,7 +561,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
559
561
if (buildLocally) {
560
562
useHook = false ;
561
563
} else {
562
- switch (tryBuildHook (inputPaths)) {
564
+ switch (tryBuildHook (inputPaths, initialOutputs )) {
563
565
case rpAccept:
564
566
/* Yes, it has started doing so. Wait until we get
565
567
EOF from the hook. */
@@ -647,8 +649,16 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
647
649
648
650
We can only early return when the outputs are known a priori. For
649
651
floating content-addressing derivations this isn't the case.
652
+
653
+ Aborts if any output is not valid or corrupt, and otherwise
654
+ returns a 'SingleDrvOutputs' structure containing all outputs.
650
655
*/
651
- assertPathValidity ();
656
+ [&] {
657
+ auto [allValid, validOutputs] = checkPathValidity (initialOutputs);
658
+ if (!allValid)
659
+ throw Error (" some outputs are unexpectedly invalid" );
660
+ return validOutputs;
661
+ }();
652
662
653
663
StorePathSet outputPaths;
654
664
for (auto & [_, output] : builtOutputs)
@@ -963,7 +973,8 @@ BuildError DerivationBuildingGoal::fixupBuilderFailureErrorMessage(BuilderFailur
963
973
return BuildError{e.status , msg};
964
974
}
965
975
966
- HookReply DerivationBuildingGoal::tryBuildHook (const StorePathSet & inputPaths)
976
+ HookReply DerivationBuildingGoal::tryBuildHook (
977
+ const StorePathSet & inputPaths, const std::map<std::string, InitialOutput> & initialOutputs)
967
978
{
968
979
#ifdef _WIN32 // TODO enable build hook on Windows
969
980
return rpDecline;
@@ -1242,7 +1253,8 @@ std::map<std::string, std::optional<StorePath>> DerivationBuildingGoal::queryPar
1242
1253
return res;
1243
1254
}
1244
1255
1245
- std::pair<bool , SingleDrvOutputs> DerivationBuildingGoal::checkPathValidity ()
1256
+ std::pair<bool , SingleDrvOutputs>
1257
+ DerivationBuildingGoal::checkPathValidity (std::map<std::string, InitialOutput> & initialOutputs)
1246
1258
{
1247
1259
if (drv->type ().isImpure ())
1248
1260
return {false , {}};
@@ -1299,14 +1311,6 @@ std::pair<bool, SingleDrvOutputs> DerivationBuildingGoal::checkPathValidity()
1299
1311
return {allValid, validOutputs};
1300
1312
}
1301
1313
1302
- SingleDrvOutputs DerivationBuildingGoal::assertPathValidity ()
1303
- {
1304
- auto [allValid, validOutputs] = checkPathValidity ();
1305
- if (!allValid)
1306
- throw Error (" some outputs are unexpectedly invalid" );
1307
- return validOutputs;
1308
- }
1309
-
1310
1314
Goal::Done DerivationBuildingGoal::doneSuccess (BuildResult::Status status, SingleDrvOutputs builtOutputs)
1311
1315
{
1312
1316
buildResult.status = status;
0 commit comments