diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index 93f20a8c3..4add710ed 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -56,14 +56,6 @@ void StoreCommand::run() 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() diff --git a/src/libcmd/command.hh b/src/libcmd/command.hh index 3aba8f25f..659b13559 100644 --- a/src/libcmd/command.hh +++ b/src/libcmd/command.hh @@ -54,8 +54,6 @@ struct EvalCommand : virtual StoreCommand, MixEvalArgs ref getEvalState(); private: - std::optional evalStoreUrl; - std::shared_ptr evalStore; std::shared_ptr evalState; diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index aa14bf79b..fb0932c00 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -61,6 +61,14 @@ MixEvalArgs::MixEvalArgs() 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) diff --git a/src/libexpr/common-eval-args.hh b/src/libexpr/common-eval-args.hh index be7fda783..0e113fff1 100644 --- a/src/libexpr/common-eval-args.hh +++ b/src/libexpr/common-eval-args.hh @@ -16,8 +16,9 @@ struct MixEvalArgs : virtual Args Strings searchPath; -private: + std::optional evalStoreUrl; +private: std::map autoArgs; }; diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 29be46cf5..4305c0ac1 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -250,8 +250,9 @@ static void main_nix_build(int argc, char * * argv) throw UsageError("'-p' and '-E' are mutually exclusive"); auto store = openStore(); + auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store; - auto state = std::make_unique(myArgs.searchPath, store); + auto state = std::make_unique(myArgs.searchPath, evalStore, store); state->repair = repair; auto autoArgs = myArgs.getAutoArgs(*state); diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index 95903d882..a269c5b5c 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -153,6 +153,7 @@ static int main_nix_instantiate(int argc, char * * argv) settings.readOnlyMode = true; auto store = openStore(); + auto evalStore = myArgs.evalStoreUrl ? openStore(*myArgs.evalStoreUrl) : store; auto state = std::make_unique(myArgs.searchPath, store); state->repair = repair;