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