|
36 | 36 |
|
37 | 37 | namespace nix { |
38 | 38 |
|
39 | | -Goal::Co DerivationGoal::init() { |
40 | | - if (useDerivation) { |
41 | | - co_return getDerivation(); |
42 | | - } else { |
43 | | - co_return haveDerivation(); |
44 | | - } |
45 | | -} |
46 | | - |
47 | 39 | DerivationGoal::DerivationGoal(const StorePath & drvPath, |
48 | 40 | const OutputsSpec & wantedOutputs, Worker & worker, BuildMode buildMode) |
49 | 41 | : Goal(worker, DerivedPath::Built { .drvPath = makeConstantStorePathRef(drvPath), .outputs = wantedOutputs }) |
@@ -141,50 +133,44 @@ void DerivationGoal::addWantedOutputs(const OutputsSpec & outputs) |
141 | 133 | } |
142 | 134 |
|
143 | 135 |
|
144 | | -Goal::Co DerivationGoal::getDerivation() |
145 | | -{ |
| 136 | +Goal::Co DerivationGoal::init() { |
146 | 137 | trace("init"); |
147 | 138 |
|
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. */ |
160 | 143 |
|
| 144 | + if (buildMode != bmNormal || !worker.evalStore.isValidPath(drvPath)) { |
| 145 | + addWaitee(upcast_goal(worker.makePathSubstitutionGoal(drvPath))); |
| 146 | + co_await Suspend{}; |
| 147 | + } |
161 | 148 |
|
162 | | -Goal::Co DerivationGoal::loadDerivation() |
163 | | -{ |
164 | | - trace("loading derivation"); |
| 149 | + trace("loading derivation"); |
165 | 150 |
|
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 | + } |
169 | 154 |
|
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); |
174 | 159 |
|
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: |
176 | 161 |
|
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. |
178 | 163 |
|
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 | + } |
185 | 171 | } |
| 172 | + assert(drv); |
186 | 173 | } |
187 | | - assert(drv); |
188 | 174 |
|
189 | 175 | co_return haveDerivation(); |
190 | 176 | } |
|
0 commit comments