File tree Expand file tree Collapse file tree 3 files changed +31
-30
lines changed
Expand file tree Collapse file tree 3 files changed +31
-30
lines changed Original file line number Diff line number Diff line change 11#include " nix/store/build/derivation-goal.hh"
2+ #include " nix/store/build/drv-output-substitution-goal.hh"
23#include " nix/store/build/derivation-building-goal.hh"
34#include " nix/store/build/derivation-resolution-goal.hh"
45#ifndef _WIN32 // TODO enable build hook on Windows
@@ -100,9 +101,24 @@ Goal::Co DerivationGoal::haveDerivation(bool storeDerivation)
100101 through substitutes. If that doesn't work, we'll build
101102 them. */
102103 if (settings.useSubstitutes && drvOptions.substitutesAllowed ()) {
103- if (!checkResult)
104- waitees.insert (upcast_goal (worker.makeDrvOutputSubstitutionGoal (DrvOutput{outputHash, wantedOutput})));
105- else {
104+ if (!checkResult) {
105+ DrvOutput id{outputHash, wantedOutput};
106+ auto g = worker.makeDrvOutputSubstitutionGoal (id);
107+ waitees.insert (g);
108+ co_await await (std::move (waitees));
109+
110+ if (nrFailed == 0 ) {
111+ waitees.insert (upcast_goal (worker.makePathSubstitutionGoal (g->outputInfo ->outPath )));
112+ co_await await (std::move (waitees));
113+
114+ trace (" output path substituted" );
115+
116+ if (nrFailed == 0 )
117+ worker.store .registerDrvOutput ({*g->outputInfo , id});
118+ else
119+ debug (" The output path of the derivation output '%s' could not be substituted" , id.to_string ());
120+ }
121+ } else {
106122 auto * cap = getDerivationCA (*drv);
107123 waitees.insert (upcast_goal (worker.makePathSubstitutionGoal (
108124 checkResult->first .outPath ,
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ Goal::Co DrvOutputSubstitutionGoal::init()
2121 trace (" init" );
2222
2323 /* If the derivation already exists, we’re done */
24- if (worker.store .queryRealisation (id)) {
24+ if ((outputInfo = worker.store .queryRealisation (id) )) {
2525 co_return amDone (ecSuccess);
2626 }
2727
@@ -70,12 +70,6 @@ Goal::Co DrvOutputSubstitutionGoal::init()
7070
7171 worker.childTerminated (this );
7272
73- /*
74- * The realisation corresponding to the given output id.
75- * Will be filled once we can get it.
76- */
77- std::shared_ptr<const UnkeyedRealisation> outputInfo;
78-
7973 try {
8074 outputInfo = promise->get_future ().get ();
8175 } catch (std::exception & e) {
@@ -86,21 +80,6 @@ Goal::Co DrvOutputSubstitutionGoal::init()
8680 if (!outputInfo)
8781 continue ;
8882
89- Goals waitees;
90-
91- waitees.insert (worker.makePathSubstitutionGoal (outputInfo->outPath ));
92-
93- co_await await (std::move (waitees));
94-
95- trace (" output path substituted" );
96-
97- if (nrFailed > 0 ) {
98- debug (" The output path of the derivation output '%s' could not be substituted" , id.to_string ());
99- co_return amDone (nrNoSubstituters > 0 ? ecNoSubstituters : ecFailed);
100- }
101-
102- worker.store .registerDrvOutput ({*outputInfo, id});
103-
10483 trace (" finished" );
10584 co_return amDone (ecSuccess);
10685 }
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ namespace nix {
1414class Worker ;
1515
1616/* *
17- * Substitution of a derivation output.
18- * This is done in three steps:
19- * 1. Fetch the output info from a substituter
20- * 2. Substitute the corresponding output path
21- * 3. Register the output info
17+ * Fetch a `Realisation` (drv ⨯ output name -> output path) from a
18+ * substituter.
19+ *
20+ * If the output store object itself should also be substituted, that is
21+ * the responsibility of the caller to do so.
2222 */
2323class DrvOutputSubstitutionGoal : public Goal
2424{
@@ -31,6 +31,12 @@ class DrvOutputSubstitutionGoal : public Goal
3131public:
3232 DrvOutputSubstitutionGoal (const DrvOutput & id, Worker & worker);
3333
34+ /* *
35+ * The realisation corresponding to the given output id.
36+ * Will be filled once we can get it.
37+ */
38+ std::shared_ptr<const UnkeyedRealisation> outputInfo;
39+
3440 Co init ();
3541
3642 void timedOut (Error && ex) override
You can’t perform that action at this time.
0 commit comments