#pragma once ///@file #include "lock.hh" #include "notifying-counter.hh" #include "store-api.hh" #include "goal.hh" namespace nix { class Worker; struct PathSubstitutionGoal : public Goal { /** * The store path that should be realised through a substitute. */ StorePath storePath; /** * The path the substituter refers to the path as. This will be * different when the stores have different names. */ std::optional subPath; /** * The remaining substituters. */ std::list> subs; /** * The current substituter. */ std::shared_ptr sub; /** * Whether a substituter failed. */ bool substituterFailed = false; /** * Path info returned by the substituter's query info operation. */ std::shared_ptr info; /** * Pipe for the substituter's standard output. */ kj::Own> outPipe; /** * The substituter thread. */ std::future thr; /** * Whether to try to repair a valid path. */ RepairFlag repair; /** * Location where we're downloading the substitute. Differs from * storePath when doing a repair. */ Path destPath; NotifyingCounter::Bump maintainExpectedSubstitutions, maintainRunningSubstitutions, maintainExpectedNar, maintainExpectedDownload; /** * Content address for recomputing store path */ std::optional ca; WorkResult done( ExitCode result, BuildResult::Status status, std::optional errorMsg = {}); public: PathSubstitutionGoal( const StorePath & storePath, Worker & worker, bool isDependency, RepairFlag repair = NoRepair, std::optional ca = std::nullopt ); ~PathSubstitutionGoal(); kj::Promise> workImpl() noexcept override; /** * The states. */ kj::Promise> tryNext() noexcept; kj::Promise> referencesValid() noexcept; kj::Promise> tryToRun() noexcept; kj::Promise> finished() noexcept; /* Called by destructor, can't be overridden */ void cleanup() override final; JobCategory jobCategory() const override { return JobCategory::Substitution; }; }; }