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;
198 std::optional<Path> buildDirOverride;
201 kj::TaskSet children;
205 std::unique_ptr<HookInstance> instance;
217 NotifyingCounter<uint64_t> doneBuilds{[
this] { updateStatisticsLater(); }};
218 NotifyingCounter<uint64_t> failedBuilds{[
this] { updateStatisticsLater(); }};
219 NotifyingCounter<uint64_t> runningBuilds{[
this] { updateStatisticsLater(); }};
221 NotifyingCounter<uint64_t> expectedSubstitutions{[
this] { updateStatisticsLater(); }};
222 NotifyingCounter<uint64_t> doneSubstitutions{[
this] { updateStatisticsLater(); }};
223 NotifyingCounter<uint64_t> failedSubstitutions{[
this] { updateStatisticsLater(); }};
224 NotifyingCounter<uint64_t> runningSubstitutions{[
this] { updateStatisticsLater(); }};
225 NotifyingCounter<uint64_t> expectedDownloadSize{[
this] { updateStatisticsLater(); }};
226 NotifyingCounter<uint64_t> doneDownloadSize{[
this] { updateStatisticsLater(); }};
227 NotifyingCounter<uint64_t> expectedNarSize{[
this] { updateStatisticsLater(); }};
228 NotifyingCounter<uint64_t> doneNarSize{[
this] { updateStatisticsLater(); }};
231 Worker(Store & store, Store & evalStore);
241 template<
typename ID, std::derived_from<Goal> G>
242 std::pair<std::shared_ptr<G>, kj::Promise<Result<Goal::WorkResult>>> makeGoalCommon(
243 std::map<ID, CachedGoal<G>> & map,
245 InvocableR<std::unique_ptr<G>>
auto create,
246 InvocableR<bool, G &>
auto modify
248 std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<Result<Goal::WorkResult>>> makeDerivationGoal(
249 const StorePath & drvPath,
250 const OutputsSpec & wantedOutputs, BuildMode buildMode = bmNormal)
override;
252 Result<std::pair<std::shared_ptr<DerivationGoal>, kj::Promise<Result<Goal::WorkResult>>>>>
253 makeBasicDerivationGoal(
254 const StorePath & drvPath,
255 const BasicDerivation & drv,
256 const OutputsSpec & wantedOutputs,
257 BuildMode buildMode = bmNormal
263 std::pair<std::shared_ptr<PathSubstitutionGoal>, kj::Promise<Result<Goal::WorkResult>>>
264 makePathSubstitutionGoal(
265 const StorePath & storePath,
266 RepairFlag repair = NoRepair,
267 std::optional<ContentAddress> ca = std::nullopt
269 std::pair<std::shared_ptr<DrvOutputSubstitutionGoal>, kj::Promise<Result<Goal::WorkResult>>>
270 makeDrvOutputSubstitutionGoal(
271 const DrvOutput &
id,
272 RepairFlag repair = NoRepair,
273 std::optional<ContentAddress> ca = std::nullopt
282 std::pair<GoalPtr, kj::Promise<Result<Goal::WorkResult>>>
283 makeGoal(
const DerivedPath & req, BuildMode buildMode = bmNormal)
override;
285 kj::Promise<Result<Results>> run(Targets topGoals);
291 kj::Promise<Result<Results>>
run(std::function<kj::Promise<Result<Targets>>(
GoalFactory &)> req)
293 co_return co_await run(TRY_AWAIT(req(goalFactory())));
295 co_return result::current_exception();
298 kj::Promise<Result<Results>> run(std::function<Targets(GoalFactory &)> req)
300 return run(req(goalFactory()));
302 return {result::current_exception()};
311 void markContentsGood(
const StorePath & path);
313 template<
typename MkGoals>
314 friend kj::Promise<Result<Results>>
315 processGoals(Store & store, Store & evalStore, MkGoals && mkGoals)
noexcept;