@@ -155,13 +155,13 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution(bool storeDerivation)
155155 are (resolved) derivation outputs in a resolved derivation. */
156156 if (&worker.evalStore != &worker.store ) {
157157 RealisedPath::Set inputSrcs;
158- for (auto & i : drv->inputSrcs )
158+ for (auto & i : drv->inputs . srcs )
159159 if (worker.evalStore .isValidPath (i))
160160 inputSrcs.insert (i);
161161 copyClosure (worker.evalStore , worker.store , inputSrcs);
162162 }
163163
164- for (auto & i : drv->inputSrcs ) {
164+ for (auto & i : drv->inputs . srcs ) {
165165 if (worker.store .isValidPath (i))
166166 continue ;
167167 if (!worker.settings .useSubstitutes )
@@ -193,7 +193,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution(bool storeDerivation)
193193 /* Determine the full set of input paths. */
194194
195195 if (storeDerivation) {
196- assert (drv->inputDrvs .map .empty ());
196+ assert (drv->inputs . drvs .map .empty ());
197197 /* Store the resolved derivation, as part of the record of
198198 what we're actually building */
199199 worker.store .writeDerivation (*drv);
@@ -204,7 +204,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution(bool storeDerivation)
204204 {
205205 /* If we get this far, we know no dynamic drvs inputs */
206206
207- for (auto & [depDrvPath, depNode] : drv->inputDrvs .map ) {
207+ for (auto & [depDrvPath, depNode] : drv->inputs . drvs .map ) {
208208 for (auto & outputName : depNode.value ) {
209209 /* Don't need to worry about `inputGoals`, because
210210 impure derivations are always resolved above. Can
@@ -232,7 +232,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution(bool storeDerivation)
232232 }
233233
234234 /* Second, the input sources. */
235- worker.store .computeFSClosure (drv->inputSrcs , inputPaths);
235+ worker.store .computeFSClosure (drv->inputs . srcs , inputPaths);
236236
237237 debug (" added input paths %s" , concatMapStringsSep (" , " , inputPaths, [&](auto & p) {
238238 return " '" + worker.store .printStorePath (p) + " '" ;
@@ -336,36 +336,26 @@ static BuildError reject(const LocalBuildRejection & rejection, std::string_view
336336
337337Goal::Co DerivationBuildingGoal::tryToBuild (StorePathSet inputPaths)
338338{
339+ /* Project down to the `BasicDerivation` the builder consumes. */
340+ BasicDerivation resolvedDrv{
341+ .outputs = drv->outputs ,
342+ .inputs = drv->inputs .srcs ,
343+ .platform = drv->platform ,
344+ .builder = drv->builder ,
345+ .args = drv->args ,
346+ .env = drv->env ,
347+ .structuredAttrs = drv->structuredAttrs ,
348+ .name = drv->name ,
349+ };
350+
339351 auto drvOptions = [&] {
340- DerivationOptions<SingleDerivedPath> temp;
341352 try {
342- temp =
343- derivationOptionsFromStructuredAttrs ( worker.store , drv-> inputDrvs , drv-> env , get (drv-> structuredAttrs ));
353+ return derivationOptionsFromStructuredAttrs (
354+ worker.store , resolvedDrv. env , get (resolvedDrv. structuredAttrs ));
344355 } catch (Error & e) {
345356 e.addTrace ({}, " while parsing derivation '%s'" , worker.store .printStorePath (drvPath));
346357 throw ;
347358 }
348-
349- auto res = tryResolve (
350- temp,
351- [&](ref<const SingleDerivedPath> drvPath, const std::string & outputName) -> std::optional<StorePath> {
352- try {
353- return resolveDerivedPath (
354- worker.store , SingleDerivedPath::Built{drvPath, outputName}, &worker.evalStore );
355- } catch (Error &) {
356- return std::nullopt ;
357- }
358- });
359-
360- /* The derivation must have all of its inputs gotten this point,
361- so the resolution will surely succeed.
362-
363- (Actually, we shouldn't even enter this goal until we have a
364- resolved derivation, or derivation with only input addressed
365- transitive inputs, so this should be a no-opt anyways.)
366- */
367- assert (res);
368- return *res;
369359 }();
370360
371361 std::map<std::string, InitialOutput> initialOutputs;
@@ -521,7 +511,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)
521511 if (valid)
522512 co_return doneSuccess (BuildResult::Success::AlreadyValid, checkPathValidity (initialOutputs).second );
523513
524- switch (tryBuildHook (drvOptions)) {
514+ switch (tryBuildHook (resolvedDrv, drvOptions)) {
525515 case rpAccept:
526516 /* Yes, it has started doing so. Wait until we get
527517 EOF from the hook. */
@@ -532,8 +522,6 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)
532522 // We should do it ourselves.
533523 co_return Return{};
534524 case rpPostpone:
535- /* Not now; wait until at least one child finishes or
536- the wake-up timeout expires. */
537525 break ;
538526 }
539527 }
@@ -554,7 +542,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)
554542 if (valid)
555543 break ;
556544
557- switch (tryBuildHook (drvOptions)) {
545+ switch (tryBuildHook (resolvedDrv, drvOptions)) {
558546 case rpAccept:
559547 /* Yes, it has started doing so. Wait until we get
560548 EOF from the hook. */
@@ -590,7 +578,12 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)
590578
591579 valid = true ;
592580 co_return buildLocally (
593- *cap, std::move (inputPaths), std::move (initialOutputs), std::move (drvOptions), std::move (outputLocks));
581+ *cap,
582+ resolvedDrv,
583+ std::move (inputPaths),
584+ std::move (initialOutputs),
585+ std::move (drvOptions),
586+ std::move (outputLocks));
594587 }
595588
596589 co_return Return{};
@@ -860,6 +853,7 @@ Goal::Co DerivationBuildingGoal::buildWithHook(
860853
861854Goal::Co DerivationBuildingGoal::buildLocally (
862855 LocalBuildCapability localBuildCap,
856+ BasicDerivation resolvedDrv,
863857 StorePathSet inputPaths,
864858 std::map<std::string, InitialOutput> initialOutputs,
865859 DerivationOptions<StorePath> drvOptions,
@@ -975,7 +969,7 @@ Goal::Co DerivationBuildingGoal::buildLocally(
975969 DerivationBuilderParams params{
976970 .drvPath = drvPath,
977971 .buildResult = buildResult,
978- .drv = *drv ,
972+ .drv = resolvedDrv ,
979973 .drvOptions = drvOptions,
980974 .inputPaths = inputPaths,
981975 .initialOutputs = initialOutputs,
@@ -1187,7 +1181,8 @@ BuildError DerivationBuildingGoal::fixupBuilderFailureErrorMessage(BuilderFailur
11871181 return BuildError{e.status , msg};
11881182}
11891183
1190- HookReply DerivationBuildingGoal::tryBuildHook (const DerivationOptions<StorePath> & drvOptions)
1184+ HookReply DerivationBuildingGoal::tryBuildHook (
1185+ const BasicDerivation & resolvedDrv, const DerivationOptions<StorePath> & drvOptions)
11911186{
11921187#ifdef _WIN32 // TODO enable build hook on Windows
11931188 return rpDecline;
@@ -1205,7 +1200,7 @@ HookReply DerivationBuildingGoal::tryBuildHook(const DerivationOptions<StorePath
12051200 /* Send the request to the hook. */
12061201 worker.hook ->sink << " try" << (worker.getNrLocalBuilds () < worker.settings .maxBuildJobs ? 1 : 0 )
12071202 << drv->platform << worker.store .printStorePath (drvPath)
1208- << drvOptions.getRequiredSystemFeatures (*drv );
1203+ << drvOptions.getRequiredSystemFeatures (resolvedDrv );
12091204 worker.hook ->sink .flush ();
12101205
12111206 /* Read the first line of input, which should be a word indicating
0 commit comments