mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-09-22 17:28:05 +03:00
0746951be1
* Finish converting existing comments for internal API docs 99% of this was just reformatting existing comments. Only two exceptions: - Expanded upon `BuildResult::status` compat note - Split up file-level `symbol-table.hh` doc comments to get per-definition docs Also fixed a few whitespace goofs, turning leading tabs to spaces and removing trailing spaces. Picking up from #8133 * Fix two things from comments * Use triple-backtick not indent for `dumpPath` * Convert GNU-style `\`..'` quotes to markdown style in API docs This will render correctly.
121 lines
2.6 KiB
C++
121 lines
2.6 KiB
C++
#pragma once
|
|
///@file
|
|
|
|
#include "lock.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<StorePath> subPath;
|
|
|
|
/**
|
|
* The remaining substituters.
|
|
*/
|
|
std::list<ref<Store>> subs;
|
|
|
|
/**
|
|
* The current substituter.
|
|
*/
|
|
std::shared_ptr<Store> sub;
|
|
|
|
/**
|
|
* Whether a substituter failed.
|
|
*/
|
|
bool substituterFailed = false;
|
|
|
|
/**
|
|
* Path info returned by the substituter's query info operation.
|
|
*/
|
|
std::shared_ptr<const ValidPathInfo> info;
|
|
|
|
/**
|
|
* Pipe for the substituter's standard output.
|
|
*/
|
|
Pipe outPipe;
|
|
|
|
/**
|
|
* The substituter thread.
|
|
*/
|
|
std::thread thr;
|
|
|
|
std::promise<void> promise;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
std::unique_ptr<MaintainCount<uint64_t>> maintainExpectedSubstitutions,
|
|
maintainRunningSubstitutions, maintainExpectedNar, maintainExpectedDownload;
|
|
|
|
typedef void (PathSubstitutionGoal::*GoalState)();
|
|
GoalState state;
|
|
|
|
/**
|
|
* Content address for recomputing store path
|
|
*/
|
|
std::optional<ContentAddress> ca;
|
|
|
|
void done(
|
|
ExitCode result,
|
|
BuildResult::Status status,
|
|
std::optional<std::string> errorMsg = {});
|
|
|
|
public:
|
|
PathSubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt);
|
|
~PathSubstitutionGoal();
|
|
|
|
void timedOut(Error && ex) override { abort(); };
|
|
|
|
/**
|
|
* We prepend "a$" to the key name to ensure substitution goals
|
|
* happen before derivation goals.
|
|
*/
|
|
std::string key() override
|
|
{
|
|
return "a$" + std::string(storePath.name()) + "$" + worker.store.printStorePath(storePath);
|
|
}
|
|
|
|
void work() override;
|
|
|
|
/**
|
|
* The states.
|
|
*/
|
|
void init();
|
|
void tryNext();
|
|
void gotInfo();
|
|
void referencesValid();
|
|
void tryToRun();
|
|
void finished();
|
|
|
|
/**
|
|
* Callback used by the worker to write to the log.
|
|
*/
|
|
void handleChildOutput(int fd, std::string_view data) override;
|
|
void handleEOF(int fd) override;
|
|
|
|
void cleanup() override;
|
|
};
|
|
|
|
}
|