Skip to content

Commit cf0df26

Browse files
authored
Merge pull request #13240 from obsidiansystems/dyn-drv-take-3
Get rid of `addWantedOutputs`
2 parents ab5fc30 + a55806a commit cf0df26

17 files changed

+478
-358
lines changed

src/libfetchers/include/nix/fetchers/input-cache.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "fetchers.hh"
1+
#include "nix/fetchers/fetchers.hh"
22

33
namespace nix::fetchers {
44

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "nix/store/build/derivation-building-goal.hh"
2-
#include "nix/store/build/derivation-goal.hh"
2+
#include "nix/store/build/derivation-trampoline-goal.hh"
33
#ifndef _WIN32 // TODO enable build hook on Windows
44
# include "nix/store/build/hook-instance.hh"
55
# include "nix/store/build/derivation-builder.hh"
@@ -72,7 +72,7 @@ std::string DerivationBuildingGoal::key()
7272
/* Ensure that derivations get built in order of their name,
7373
i.e. a derivation named "aardvark" always comes before
7474
"baboon". And substitution goals always happen before
75-
derivation goals (due to "b$"). */
75+
derivation goals (due to "bd$"). */
7676
return "bd$" + std::string(drvPath.name()) + "$" + worker.store.printStorePath(drvPath);
7777
}
7878

@@ -266,7 +266,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
266266
auto mEntry = get(inputGoals, drvPath);
267267
if (!mEntry) return std::nullopt;
268268

269-
auto buildResult = (*mEntry)->getBuildResult(DerivedPath::Built{drvPath, OutputsSpec::Names{outputName}});
269+
auto & buildResult = (*mEntry)->buildResult;
270270
if (!buildResult.success()) return std::nullopt;
271271

272272
auto i = get(buildResult.builtOutputs, outputName);
@@ -296,30 +296,28 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
296296
worker.store.printStorePath(pathResolved),
297297
});
298298

299-
// FIXME wanted outputs
300-
auto resolvedDrvGoal = worker.makeDerivationGoal(
301-
makeConstantStorePathRef(pathResolved), OutputsSpec::All{}, buildMode);
299+
/* TODO https://github.com/NixOS/nix/issues/13247 we should
300+
let the calling goal do this, so it has a change to pass
301+
just the output(s) it cares about. */
302+
auto resolvedDrvGoal = worker.makeDerivationTrampolineGoal(
303+
pathResolved, OutputsSpec::All{}, drvResolved, buildMode);
302304
{
303305
Goals waitees{resolvedDrvGoal};
304306
co_await await(std::move(waitees));
305307
}
306308

307309
trace("resolved derivation finished");
308310

309-
auto resolvedDrv = *resolvedDrvGoal->drv;
310-
auto resolvedResult = resolvedDrvGoal->getBuildResult(DerivedPath::Built{
311-
.drvPath = makeConstantStorePathRef(pathResolved),
312-
.outputs = OutputsSpec::All{},
313-
});
311+
auto resolvedResult = resolvedDrvGoal->buildResult;
314312

315313
SingleDrvOutputs builtOutputs;
316314

317315
if (resolvedResult.success()) {
318-
auto resolvedHashes = staticOutputHashes(worker.store, resolvedDrv);
316+
auto resolvedHashes = staticOutputHashes(worker.store, drvResolved);
319317

320318
StorePathSet outputPaths;
321319

322-
for (auto & outputName : resolvedDrv.outputNames()) {
320+
for (auto & outputName : drvResolved.outputNames()) {
323321
auto initialOutput = get(initialOutputs, outputName);
324322
auto resolvedHash = get(resolvedHashes, outputName);
325323
if ((!initialOutput) || (!resolvedHash))
@@ -340,7 +338,7 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution()
340338

341339
throw Error(
342340
"derivation '%s' doesn't have expected output '%s' (derivation-goal.cc/realisation)",
343-
resolvedDrvGoal->drvReq->to_string(worker.store), outputName);
341+
worker.store.printStorePath(pathResolved), outputName);
344342
}();
345343

346344
if (!drv->type().isImpure()) {

0 commit comments

Comments
 (0)