Support --eval-store in nix-instantiate and nix-build

This commit is contained in:
Eelco Dolstra 2021-07-15 14:28:33 +02:00
parent 3d9de41a5b
commit 2ff3035cf4
6 changed files with 13 additions and 12 deletions

View file

@ -56,14 +56,6 @@ void StoreCommand::run()
EvalCommand::EvalCommand() EvalCommand::EvalCommand()
{ {
// FIXME: move to MixEvalArgs?
addFlag({
.longName = "eval-store",
.description = "The Nix store to use for evaluations.",
.labels = {"store-url"},
//.category = ...,
.handler = {&evalStoreUrl},
});
} }
EvalCommand::~EvalCommand() EvalCommand::~EvalCommand()

View file

@ -54,8 +54,6 @@ struct EvalCommand : virtual StoreCommand, MixEvalArgs
ref<EvalState> getEvalState(); ref<EvalState> getEvalState();
private: private:
std::optional<std::string> evalStoreUrl;
std::shared_ptr<Store> evalStore; std::shared_ptr<Store> evalStore;
std::shared_ptr<EvalState> evalState; std::shared_ptr<EvalState> evalState;

View file

@ -61,6 +61,14 @@ MixEvalArgs::MixEvalArgs()
fetchers::overrideRegistry(from.input, to.input, extraAttrs); fetchers::overrideRegistry(from.input, to.input, extraAttrs);
}} }}
}); });
addFlag({
.longName = "eval-store",
.description = "The Nix store to use for evaluations.",
.category = category,
.labels = {"store-url"},
.handler = {&evalStoreUrl},
});
} }
Bindings * MixEvalArgs::getAutoArgs(EvalState & state) Bindings * MixEvalArgs::getAutoArgs(EvalState & state)

View file

@ -16,8 +16,9 @@ struct MixEvalArgs : virtual Args
Strings searchPath; Strings searchPath;
private: std::optional<std::string> evalStoreUrl;
private:
std::map<std::string, std::string> autoArgs; std::map<std::string, std::string> autoArgs;
}; };

View file

@ -250,8 +250,9 @@ static void main_nix_build(int argc, char * * argv)
throw UsageError("'-p' and '-E' are mutually exclusive"); throw UsageError("'-p' and '-E' are mutually exclusive");
auto store = openStore(); auto store = openStore();
auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store;
auto state = std::make_unique<EvalState>(myArgs.searchPath, store); auto state = std::make_unique<EvalState>(myArgs.searchPath, evalStore, store);
state->repair = repair; state->repair = repair;
auto autoArgs = myArgs.getAutoArgs(*state); auto autoArgs = myArgs.getAutoArgs(*state);

View file

@ -153,6 +153,7 @@ static int main_nix_instantiate(int argc, char * * argv)
settings.readOnlyMode = true; settings.readOnlyMode = true;
auto store = openStore(); auto store = openStore();
auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store;
auto state = std::make_unique<EvalState>(myArgs.searchPath, store); auto state = std::make_unique<EvalState>(myArgs.searchPath, store);
state->repair = repair; state->repair = repair;