1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 07:22:43 +01:00

nix list-tarballs: Revive

This commit is contained in:
Eelco Dolstra 2020-02-13 16:21:58 +01:00
parent ca2dee6e7d
commit eb319c8078
3 changed files with 15 additions and 21 deletions

View file

@ -350,7 +350,7 @@ private:
public: public:
std::function<void(const Path & drvPath, const Derivation & drv)> derivationHook; std::function<void(const StorePath & drvPath, const Derivation & drv)> derivationHook;
}; };

View file

@ -749,7 +749,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
auto drvPath = writeDerivation(state.store, drv, drvName, state.repair); auto drvPath = writeDerivation(state.store, drv, drvName, state.repair);
auto drvPathS = state.store->printStorePath(drvPath); 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); printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS);

View file

@ -1,4 +1,3 @@
#if 0
#include "command.hh" #include "command.hh"
#include "eval.hh" #include "eval.hh"
#include "eval-inline.hh" #include "eval-inline.hh"
@ -10,11 +9,6 @@ using namespace nix;
struct CmdListTarballs : MixJSON, InstallablesCommand struct CmdListTarballs : MixJSON, InstallablesCommand
{ {
std::string name() override
{
return "list-tarballs";
}
std::string description() override std::string description() override
{ {
return "list the 'fetchurl' calls made by the dependency graph of a package"; return "list the 'fetchurl' calls made by the dependency graph of a package";
@ -36,7 +30,7 @@ struct CmdListTarballs : MixJSON, InstallablesCommand
bool recursive; bool recursive;
Hash hash; Hash hash;
std::string url; std::string url;
Path storePath; StorePath storePath;
}; };
void doIt(ref<Store> store, std::function<void(const File &)> callback) void doIt(ref<Store> store, std::function<void(const File &)> callback)
@ -46,17 +40,17 @@ struct CmdListTarballs : MixJSON, InstallablesCommand
auto state = getEvalState(); auto state = getEvalState();
auto autoArgs = getAutoArgs(*state); auto autoArgs = getAutoArgs(*state);
PathSet done; StorePathSet done;
state->derivationHook = state->derivationHook =
[&](const Path & drvPath, const Derivation & drv) { [&](const StorePath & drvPath, const Derivation & drv) {
if (drv.outputs.size() != 1) return; if (drv.outputs.size() != 1) return;
auto & output = *drv.outputs.begin(); auto & output = *drv.outputs.begin();
if (output.second.hashAlgo.empty() || output.second.hash.empty()) return; 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(); auto [recursive, hash] = output.second.parseHashInfo();
@ -75,12 +69,13 @@ struct CmdListTarballs : MixJSON, InstallablesCommand
url = urls[0]; url = urls[0];
} }
File file; File file {
file.type = drv.builder == "builtin:fetchurl" ? "fetchurl" : "unknown"; .type = drv.builder == "builtin:fetchurl" ? "fetchurl" : "unknown",
file.recursive = recursive; .recursive = recursive,
file.hash = hash; .hash = hash,
file.url = *url; .url = *url,
file.storePath = output.second.path; .storePath = output.second.path.clone()
};
callback(file); callback(file);
}; };
@ -127,7 +122,7 @@ struct CmdListTarballs : MixJSON, InstallablesCommand
obj.attr("recursive", true); obj.attr("recursive", true);
obj.attr("hash", file.hash.to_string(SRI)); obj.attr("hash", file.hash.to_string(SRI));
obj.attr("url", file.url); obj.attr("url", file.url);
obj.attr("storePath", file.storePath); obj.attr("storePath", store->printStorePath(file.storePath));
}); });
} else { } else {
doIt(store, doIt(store,
@ -138,5 +133,4 @@ struct CmdListTarballs : MixJSON, InstallablesCommand
} }
}; };
static RegisterCommand r1(make_ref<CmdListTarballs>()); static auto r1 = registerCommand<CmdListTarballs>("list-tarballs");
#endif