|
1 | 1 | #include "nix/store/build/derivation-building-goal.hh" |
2 | | -#include "nix/store/build/derivation-resolution-goal.hh" |
3 | 2 | #include "nix/store/build/derivation-env-desugar.hh" |
4 | | -#include "nix/store/build/derivation-trampoline-goal.hh" |
5 | 3 | #ifndef _WIN32 // TODO enable build hook on Windows |
6 | 4 | # include "nix/store/build/hook-instance.hh" |
7 | 5 | # include "nix/store/build/derivation-builder.hh" |
@@ -175,107 +173,6 @@ Goal::Co DerivationBuildingGoal::gaveUpOnSubstitution() |
175 | 173 | /* Determine the full set of input paths. */ |
176 | 174 |
|
177 | 175 | { |
178 | | - auto resolutionGoal = worker.makeDerivationResolutionGoal(drvPath, *drv, buildMode); |
179 | | - { |
180 | | - Goals waitees{resolutionGoal}; |
181 | | - co_await await(std::move(waitees)); |
182 | | - } |
183 | | - if (nrFailed != 0) { |
184 | | - co_return doneFailure({BuildResult::Failure::DependencyFailed, "resolution failed"}); |
185 | | - } |
186 | | - |
187 | | - if (resolutionGoal->resolvedDrv) { |
188 | | - auto & [pathResolved, drvResolved] = *resolutionGoal->resolvedDrv; |
189 | | - |
190 | | - /* Store the resolved derivation, as part of the record of |
191 | | - what we're actually building */ |
192 | | - writeDerivation(worker.store, drvResolved); |
193 | | - |
194 | | - /* TODO https://github.com/NixOS/nix/issues/13247 we should |
195 | | - let the calling goal do this, so it has a change to pass |
196 | | - just the output(s) it cares about. */ |
197 | | - auto resolvedDrvGoal = |
198 | | - worker.makeDerivationTrampolineGoal(pathResolved, OutputsSpec::All{}, drvResolved, buildMode); |
199 | | - { |
200 | | - Goals waitees{resolvedDrvGoal}; |
201 | | - co_await await(std::move(waitees)); |
202 | | - } |
203 | | - |
204 | | - trace("resolved derivation finished"); |
205 | | - |
206 | | - auto resolvedResult = resolvedDrvGoal->buildResult; |
207 | | - |
208 | | - // No `std::visit` for coroutines yet |
209 | | - if (auto * successP = resolvedResult.tryGetSuccess()) { |
210 | | - auto & success = *successP; |
211 | | - SingleDrvOutputs builtOutputs; |
212 | | - |
213 | | - auto outputHashes = staticOutputHashes(worker.evalStore, *drv); |
214 | | - auto resolvedHashes = staticOutputHashes(worker.store, drvResolved); |
215 | | - |
216 | | - StorePathSet outputPaths; |
217 | | - |
218 | | - for (auto & outputName : drvResolved.outputNames()) { |
219 | | - auto outputHash = get(outputHashes, outputName); |
220 | | - auto resolvedHash = get(resolvedHashes, outputName); |
221 | | - if ((!outputHash) || (!resolvedHash)) |
222 | | - throw Error( |
223 | | - "derivation '%s' doesn't have expected output '%s' (derivation-goal.cc/resolve)", |
224 | | - worker.store.printStorePath(drvPath), |
225 | | - outputName); |
226 | | - |
227 | | - auto realisation = [&] { |
228 | | - auto take1 = get(success.builtOutputs, outputName); |
229 | | - if (take1) |
230 | | - return *take1; |
231 | | - |
232 | | - /* The above `get` should work. But stateful tracking of |
233 | | - outputs in resolvedResult, this can get out of sync with the |
234 | | - store, which is our actual source of truth. For now we just |
235 | | - check the store directly if it fails. */ |
236 | | - auto take2 = worker.evalStore.queryRealisation(DrvOutput{*resolvedHash, outputName}); |
237 | | - if (take2) |
238 | | - return *take2; |
239 | | - |
240 | | - throw Error( |
241 | | - "derivation '%s' doesn't have expected output '%s' (derivation-goal.cc/realisation)", |
242 | | - worker.store.printStorePath(pathResolved), |
243 | | - outputName); |
244 | | - }(); |
245 | | - |
246 | | - if (!drv->type().isImpure()) { |
247 | | - auto newRealisation = realisation; |
248 | | - newRealisation.id = DrvOutput{*outputHash, outputName}; |
249 | | - newRealisation.signatures.clear(); |
250 | | - if (!drv->type().isFixed()) { |
251 | | - auto & drvStore = worker.evalStore.isValidPath(drvPath) ? worker.evalStore : worker.store; |
252 | | - newRealisation.dependentRealisations = |
253 | | - drvOutputReferences(worker.store, *drv, realisation.outPath, &drvStore); |
254 | | - } |
255 | | - worker.store.signRealisation(newRealisation); |
256 | | - worker.store.registerDrvOutput(newRealisation); |
257 | | - } |
258 | | - outputPaths.insert(realisation.outPath); |
259 | | - builtOutputs.emplace(outputName, realisation); |
260 | | - } |
261 | | - |
262 | | - runPostBuildHook(worker.store, *logger, drvPath, outputPaths); |
263 | | - |
264 | | - auto status = success.status; |
265 | | - if (status == BuildResult::Success::AlreadyValid) |
266 | | - status = BuildResult::Success::ResolvesToAlreadyValid; |
267 | | - |
268 | | - co_return doneSuccess(success.status, std::move(builtOutputs)); |
269 | | - } else if (resolvedResult.tryGetFailure()) { |
270 | | - co_return doneFailure({ |
271 | | - BuildResult::Failure::DependencyFailed, |
272 | | - "build of resolved derivation '%s' failed", |
273 | | - worker.store.printStorePath(pathResolved), |
274 | | - }); |
275 | | - } else |
276 | | - assert(false); |
277 | | - } |
278 | | - |
279 | 176 | /* If we get this far, we know no dynamic drvs inputs */ |
280 | 177 |
|
281 | 178 | for (auto & [depDrvPath, depNode] : drv->inputDrvs.map) { |
|
0 commit comments