Skip to content

Commit 4f96f24

Browse files
committed
Inline getDerivation and loadDerivation
1 parent 8b999e7 commit 4f96f24

File tree

2 files changed

+27
-43
lines changed

2 files changed

+27
-43
lines changed

src/libstore/build/derivation-goal.cc

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@
3636

3737
namespace nix {
3838

39-
Goal::Co DerivationGoal::init() {
40-
if (useDerivation) {
41-
co_return getDerivation();
42-
} else {
43-
co_return haveDerivation();
44-
}
45-
}
46-
4739
DerivationGoal::DerivationGoal(const StorePath & drvPath,
4840
const OutputsSpec & wantedOutputs, Worker & worker, BuildMode buildMode)
4941
: Goal(worker, DerivedPath::Built { .drvPath = makeConstantStorePathRef(drvPath), .outputs = wantedOutputs })
@@ -141,50 +133,44 @@ void DerivationGoal::addWantedOutputs(const OutputsSpec & outputs)
141133
}
142134

143135

144-
Goal::Co DerivationGoal::getDerivation()
145-
{
136+
Goal::Co DerivationGoal::init() {
146137
trace("init");
147138

148-
/* The first thing to do is to make sure that the derivation
149-
exists. If it doesn't, it may be created through a
150-
substitute. */
151-
if (buildMode == bmNormal && worker.evalStore.isValidPath(drvPath)) {
152-
co_return loadDerivation();
153-
}
154-
155-
addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath)));
156-
157-
co_await Suspend{};
158-
co_return loadDerivation();
159-
}
139+
if (useDerivation) {
140+
/* The first thing to do is to make sure that the derivation
141+
exists. If it doesn't, it may be created through a
142+
substitute. */
160143

144+
if (buildMode != bmNormal || !worker.evalStore.isValidPath(drvPath)) {
145+
addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath)));
146+
co_await Suspend{};
147+
}
161148

162-
Goal::Co DerivationGoal::loadDerivation()
163-
{
164-
trace("loading derivation");
149+
trace("loading derivation");
165150

166-
if (nrFailed != 0) {
167-
co_return done(BuildResult::MiscFailure, {}, Error("cannot build missing derivation '%s'", worker.store.printStorePath(drvPath)));
168-
}
151+
if (nrFailed != 0) {
152+
co_return done(BuildResult::MiscFailure, {}, Error("cannot build missing derivation '%s'", worker.store.printStorePath(drvPath)));
153+
}
169154

170-
/* `drvPath' should already be a root, but let's be on the safe
171-
side: if the user forgot to make it a root, we wouldn't want
172-
things being garbage collected while we're busy. */
173-
worker.evalStore.addTempRoot(drvPath);
155+
/* `drvPath' should already be a root, but let's be on the safe
156+
side: if the user forgot to make it a root, we wouldn't want
157+
things being garbage collected while we're busy. */
158+
worker.evalStore.addTempRoot(drvPath);
174159

175-
/* Get the derivation. It is probably in the eval store, but it might be inthe main store:
160+
/* Get the derivation. It is probably in the eval store, but it might be inthe main store:
176161
177-
- Resolved derivation are resolved against main store realisations, and so must be stored there.
162+
- Resolved derivation are resolved against main store realisations, and so must be stored there.
178163
179-
- Dynamic derivations are built, and so are found in the main store.
180-
*/
181-
for (auto * drvStore : { &worker.evalStore, &worker.store }) {
182-
if (drvStore->isValidPath(drvPath)) {
183-
drv = std::make_unique<Derivation>(drvStore->readDerivation(drvPath));
184-
break;
164+
- Dynamic derivations are built, and so are found in the main store.
165+
*/
166+
for (auto * drvStore : { &worker.evalStore, &worker.store }) {
167+
if (drvStore->isValidPath(drvPath)) {
168+
drv = std::make_unique<Derivation>(drvStore->readDerivation(drvPath));
169+
break;
170+
}
185171
}
172+
assert(drv);
186173
}
187-
assert(drv);
188174

189175
co_return haveDerivation();
190176
}

src/libstore/build/derivation-goal.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ struct DerivationGoal : public Goal
233233
* The states.
234234
*/
235235
Co init() override;
236-
Co getDerivation();
237-
Co loadDerivation();
238236
Co haveDerivation();
239237
Co gaveUpOnSubstitution();
240238
Co tryToBuild();

0 commit comments

Comments
 (0)