From eb319c80780a3ae75d0dd6abb0039849484df2ed Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 13 Feb 2020 16:21:58 +0100 Subject: [PATCH] nix list-tarballs: Revive --- src/libexpr/eval.hh | 2 +- src/libexpr/primops.cc | 2 +- src/nix/list-tarballs.cc | 32 +++++++++++++------------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 5b027535d..694d558f4 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -350,7 +350,7 @@ private: public: - std::function derivationHook; + std::function derivationHook; }; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 84cd7f377..6d07dfce5 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -749,7 +749,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * * auto drvPath = writeDerivation(state.store, drv, drvName, state.repair); auto drvPathS = state.store->printStorePath(drvPath); - if (state.derivationHook) state.derivationHook(drvPathS, drv); + if (state.derivationHook) state.derivationHook(drvPath, drv); printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS); diff --git a/src/nix/list-tarballs.cc b/src/nix/list-tarballs.cc index ebf77433f..f74ba93bd 100644 --- a/src/nix/list-tarballs.cc +++ b/src/nix/list-tarballs.cc @@ -1,4 +1,3 @@ -#if 0 #include "command.hh" #include "eval.hh" #include "eval-inline.hh" @@ -10,11 +9,6 @@ using namespace nix; struct CmdListTarballs : MixJSON, InstallablesCommand { - std::string name() override - { - return "list-tarballs"; - } - std::string description() override { return "list the 'fetchurl' calls made by the dependency graph of a package"; @@ -36,7 +30,7 @@ struct CmdListTarballs : MixJSON, InstallablesCommand bool recursive; Hash hash; std::string url; - Path storePath; + StorePath storePath; }; void doIt(ref store, std::function callback) @@ -46,17 +40,17 @@ struct CmdListTarballs : MixJSON, InstallablesCommand auto state = getEvalState(); auto autoArgs = getAutoArgs(*state); - PathSet done; + StorePathSet done; state->derivationHook = - [&](const Path & drvPath, const Derivation & drv) { + [&](const StorePath & drvPath, const Derivation & drv) { if (drv.outputs.size() != 1) return; auto & output = *drv.outputs.begin(); if (output.second.hashAlgo.empty() || output.second.hash.empty()) return; - if (!done.insert(output.second.path).second) return; + if (!done.insert(output.second.path.clone()).second) return; auto [recursive, hash] = output.second.parseHashInfo(); @@ -75,12 +69,13 @@ struct CmdListTarballs : MixJSON, InstallablesCommand url = urls[0]; } - File file; - file.type = drv.builder == "builtin:fetchurl" ? "fetchurl" : "unknown"; - file.recursive = recursive; - file.hash = hash; - file.url = *url; - file.storePath = output.second.path; + File file { + .type = drv.builder == "builtin:fetchurl" ? "fetchurl" : "unknown", + .recursive = recursive, + .hash = hash, + .url = *url, + .storePath = output.second.path.clone() + }; callback(file); }; @@ -127,7 +122,7 @@ struct CmdListTarballs : MixJSON, InstallablesCommand obj.attr("recursive", true); obj.attr("hash", file.hash.to_string(SRI)); obj.attr("url", file.url); - obj.attr("storePath", file.storePath); + obj.attr("storePath", store->printStorePath(file.storePath)); }); } else { doIt(store, @@ -138,5 +133,4 @@ struct CmdListTarballs : MixJSON, InstallablesCommand } }; -static RegisterCommand r1(make_ref()); -#endif +static auto r1 = registerCommand("list-tarballs");