35 virtual std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<Result<Goal::WorkResult>>>
40 Result<std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<Result<Goal::WorkResult>>>>>
41 makeBasicDerivationGoal(
45 BuildMode buildMode = bmNormal
51 virtual std::pair<std::shared_ptr<PathSubstitutionGoal>, kj::Promise<Result<Goal::WorkResult>>>
54 RepairFlag repair = NoRepair,
55 std::optional<ContentAddress> ca = std::nullopt
57 virtual std::pair<std::shared_ptr<DrvOutputSubstitutionGoal>, kj::Promise<Result<Goal::WorkResult>>>
58 makeDrvOutputSubstitutionGoal(
60 RepairFlag repair = NoRepair,
61 std::optional<ContentAddress> ca = std::nullopt
70 virtual std::pair<GoalPtr, kj::Promise<Result<Goal::WorkResult>>>
91 using Targets = std::vector<std::pair<GoalPtr, kj::Promise<Result<Goal::WorkResult>>>>;
100 std::map<size_t, Goal::WorkResult>
goals;
128 bool running =
false;
133 std::shared_ptr<G> goal;
134 kj::ForkedPromise<Result<Goal::WorkResult>> promise{
nullptr};
140 std::map<StorePath, CachedGoal<DerivationGoal>> derivationGoals;
141 std::map<StorePath, CachedGoal<PathSubstitutionGoal>> substitutionGoals;
142 std::map<DrvOutput, CachedGoal<DrvOutputSubstitutionGoal>> drvOutputSubstitutionGoals;
147 std::map<StorePath, bool> pathContentsGoodCache;
153 bool permanentFailure =
false;
158 bool timedOut =
false;
163 bool hashMismatch =
false;
168 bool checkMismatch =
false;
173 kj::Promise<Result<Results>> updateStatistics();
175 AsyncSemaphore statisticsUpdateSignal{1};
176 std::optional<AsyncSemaphore::Token> statisticsUpdateInhibitor;
181 void updateStatisticsLater()
183 statisticsUpdateInhibitor = {};
186 kj::Promise<Result<Results>> runImpl(Targets topGoals);
187 kj::Promise<Result<Results>> boopGC(LocalStore & localStore);
192 const Activity actDerivations;
193 const Activity actSubstitutions;
197 AsyncSemaphore substitutions, localBuilds;
200 kj::TaskSet children;
204 std::unique_ptr<HookInstance> instance;
216 NotifyingCounter<uint64_t> doneBuilds{[
this] { updateStatisticsLater(); }};
217 NotifyingCounter<uint64_t> failedBuilds{[
this] { updateStatisticsLater(); }};
218 NotifyingCounter<uint64_t> runningBuilds{[
this] { updateStatisticsLater(); }};
220 NotifyingCounter<uint64_t> expectedSubstitutions{[
this] { updateStatisticsLater(); }};
221 NotifyingCounter<uint64_t> doneSubstitutions{[
this] { updateStatisticsLater(); }};
222 NotifyingCounter<uint64_t> failedSubstitutions{[
this] { updateStatisticsLater(); }};
223 NotifyingCounter<uint64_t> runningSubstitutions{[
this] { updateStatisticsLater(); }};
224 NotifyingCounter<uint64_t> expectedDownloadSize{[
this] { updateStatisticsLater(); }};
225 NotifyingCounter<uint64_t> doneDownloadSize{[
this] { updateStatisticsLater(); }};
226 NotifyingCounter<uint64_t> expectedNarSize{[
this] { updateStatisticsLater(); }};
227 NotifyingCounter<uint64_t> doneNarSize{[
this] { updateStatisticsLater(); }};
230 Worker(Store & store, Store & evalStore);
240 template<
typename ID, std::derived_from<Goal> G>
241 std::pair<std::shared_ptr<G>, kj::Promise<Result<Goal::WorkResult>>> makeGoalCommon(
242 std::map<ID, CachedGoal<G>> & map,
244 InvocableR<std::unique_ptr<G>>
auto create,
245 InvocableR<bool, G &>
auto modify
247 std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<Result<Goal::WorkResult>>> makeDerivationGoal(
248 const StorePath & drvPath,
249 const OutputsSpec & wantedOutputs, BuildMode buildMode = bmNormal)
override;
251 Result<std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<Result<Goal::WorkResult>>>>>
252 makeBasicDerivationGoal(
253 const StorePath & drvPath,
254 const BasicDerivation & drv,
255 const OutputsSpec & wantedOutputs,
256 BuildMode buildMode = bmNormal
262 std::pair<std::shared_ptr<PathSubstitutionGoal>, kj::Promise<Result<Goal::WorkResult>>>
263 makePathSubstitutionGoal(
264 const StorePath & storePath,
265 RepairFlag repair = NoRepair,
266 std::optional<ContentAddress> ca = std::nullopt
268 std::pair<std::shared_ptr<DrvOutputSubstitutionGoal>, kj::Promise<Result<Goal::WorkResult>>>
269 makeDrvOutputSubstitutionGoal(
270 const DrvOutput &
id,
271 RepairFlag repair = NoRepair,
272 std::optional<ContentAddress> ca = std::nullopt
281 std::pair<GoalPtr, kj::Promise<Result<Goal::WorkResult>>>
282 makeGoal(
const DerivedPath & req, BuildMode buildMode = bmNormal)
override;
284 kj::Promise<Result<Results>> run(Targets topGoals);
290 kj::Promise<Result<Results>>
run(std::function<kj::Promise<Result<Targets>>(
GoalFactory &)> req)
292 co_return co_await run(TRY_AWAIT(req(goalFactory())));
294 co_return result::current_exception();
297 kj::Promise<Result<Results>> run(std::function<Targets(GoalFactory &)> req)
299 return run(req(goalFactory()));
301 return {result::current_exception()};
310 void markContentsGood(
const StorePath & path);
312 template<
typename MkGoals>
313 friend kj::Promise<Result<Results>>
314 processGoals(Store & store, Store & evalStore, MkGoals && mkGoals)
noexcept;