Restructure installables handling in the "nix" command

This commit is contained in:
Eelco Dolstra 2017-04-25 11:20:37 +02:00
parent 1bb87c0487
commit bcecc99007
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
9 changed files with 265 additions and 132 deletions

View file

@ -6,7 +6,7 @@
using namespace nix;
struct CmdLog : StoreCommand, MixInstallables
struct CmdLog : MixInstallables
{
CmdLog()
{
@ -24,32 +24,23 @@ struct CmdLog : StoreCommand, MixInstallables
void run(ref<Store> store) override
{
auto elems = evalInstallables(store);
PathSet paths;
for (auto & elem : elems) {
if (elem.isDrv)
paths.insert(elem.drvPath);
else
paths.insert(elem.outPaths.begin(), elem.outPaths.end());
}
auto subs = getDefaultSubstituters();
subs.push_front(store);
for (auto & path : paths) {
bool found = false;
for (auto & sub : subs) {
auto log = sub->getBuildLog(path);
if (!log) continue;
std::cout << *log;
found = true;
break;
for (auto & inst : installables) {
for (auto & path : inst->toBuildable()) {
bool found = false;
for (auto & sub : subs) {
auto log = sub->getBuildLog(path);
if (!log) continue;
std::cout << *log;
found = true;
break;
}
if (!found)
throw Error("build log of path %s is not available", path);
}
if (!found)
throw Error("build log of path %s is not available", path);
}
}
};