1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

Inline getDerivation and loadDerivation

This commit is contained in:
John Ericson 2025-02-01 18:56:42 -05:00
parent 57463ab910
commit 2297cc0dab
2 changed files with 33 additions and 49 deletions

View file

@ -36,14 +36,6 @@
namespace nix { namespace nix {
Goal::Co DerivationGoal::init() {
if (useDerivation) {
co_return getDerivation();
} else {
co_return haveDerivation();
}
}
DerivationGoal::DerivationGoal(const StorePath & drvPath, DerivationGoal::DerivationGoal(const StorePath & drvPath,
const OutputsSpec & wantedOutputs, Worker & worker, BuildMode buildMode) const OutputsSpec & wantedOutputs, Worker & worker, BuildMode buildMode)
: Goal(worker, DerivedPath::Built { .drvPath = makeConstantStorePathRef(drvPath), .outputs = wantedOutputs }) : Goal(worker, DerivedPath::Built { .drvPath = makeConstantStorePathRef(drvPath), .outputs = wantedOutputs })
@ -141,26 +133,19 @@ void DerivationGoal::addWantedOutputs(const OutputsSpec & outputs)
} }
Goal::Co DerivationGoal::getDerivation() Goal::Co DerivationGoal::init() {
{
trace("init"); trace("init");
if (useDerivation) {
/* The first thing to do is to make sure that the derivation /* The first thing to do is to make sure that the derivation
exists. If it doesn't, it may be created through a exists. If it doesn't, it may be created through a
substitute. */ substitute. */
if (buildMode == bmNormal && worker.evalStore.isValidPath(drvPath)) {
co_return loadDerivation(); if (buildMode != bmNormal || !worker.evalStore.isValidPath(drvPath)) {
addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath)));
co_await Suspend{};
} }
addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath)));
co_await Suspend{};
co_return loadDerivation();
}
Goal::Co DerivationGoal::loadDerivation()
{
trace("loading derivation"); trace("loading derivation");
if (nrFailed != 0) { if (nrFailed != 0) {
@ -185,6 +170,7 @@ Goal::Co DerivationGoal::loadDerivation()
} }
} }
assert(drv); assert(drv);
}
co_return haveDerivation(); co_return haveDerivation();
} }

View file

@ -233,8 +233,6 @@ struct DerivationGoal : public Goal
* The states. * The states.
*/ */
Co init() override; Co init() override;
Co getDerivation();
Co loadDerivation();
Co haveDerivation(); Co haveDerivation();
Co gaveUpOnSubstitution(); Co gaveUpOnSubstitution();
Co inputsRealised(); Co inputsRealised();