From bef40c29491ba9b31c85b9b89a5342979344f583 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 29 Jun 2021 21:09:48 +0200 Subject: Add --eval-store option --- src/libcmd/command.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/libcmd/command.cc') diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index 6777b23be..93f20a8c3 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -54,6 +54,38 @@ void StoreCommand::run() run(getStore()); } +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() +{ + if (evalState) + evalState->printStats(); +} + +ref EvalCommand::getEvalStore() +{ + if (!evalStore) + evalStore = evalStoreUrl ? openStore(*evalStoreUrl) : getStore(); + return ref(evalStore); +} + +ref EvalCommand::getEvalState() +{ + if (!evalState) + evalState = std::make_shared(searchPath, getEvalStore(), getStore()); + return ref(evalState); +} + BuiltPathsCommand::BuiltPathsCommand(bool recursive) : recursive(recursive) { -- cgit v1.2.3 From 2ff3035cf4d5167d180878d69cb47b31890a24c4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 15 Jul 2021 14:28:33 +0200 Subject: Support --eval-store in nix-instantiate and nix-build --- src/libcmd/command.cc | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/libcmd/command.cc') 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() -- cgit v1.2.3 From 8d9f7048cd3b09fb58f6bad0328f644b0ddaaa16 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 16 Jul 2021 16:04:47 +0200 Subject: Use eval-store in more places In particular, this now works: $ nix path-info --eval-store auto --store https://cache.nixos.org nixpkgs#hello Previously this would fail as it would try to upload the hello .drv to cache.nixos.org. Now the .drv is instantiated in the local store, and then we check for the existence of the outputs in cache.nixos.org. --- src/libcmd/command.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libcmd/command.cc') diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index 4add710ed..2daf43aa7 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -115,7 +115,7 @@ void BuiltPathsCommand::run(ref store) for (auto & p : store->queryAllValidPaths()) paths.push_back(BuiltPath::Opaque{p}); } else { - paths = toBuiltPaths(store, realiseMode, operateOn, installables); + paths = toBuiltPaths(getEvalStore(), store, realiseMode, operateOn, installables); if (recursive) { // XXX: This only computes the store path closure, ignoring // intermediate realisations -- cgit v1.2.3