1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 01:11:15 +02:00

nix flake info --json: Show TreeInfo

This commit is contained in:
Eelco Dolstra 2020-04-02 11:51:34 +02:00
parent 74024515a3
commit ed13457dbf
4 changed files with 7 additions and 19 deletions

View file

@ -76,18 +76,6 @@ LockedNode::LockedNode(const nlohmann::json & json)
throw Error("lockfile contains mutable flakeref '%s'", lockedRef);
}
static nlohmann::json treeInfoToJson(const TreeInfo & info)
{
nlohmann::json json;
assert(info.narHash);
json["narHash"] = info.narHash.to_string(SRI);
if (info.revCount)
json["revCount"] = *info.revCount;
if (info.lastModified)
json["lastModified"] = *info.lastModified;
return json;
}
StorePath LockedNode::computeStorePath(Store & store) const
{
return info.computeStorePath(store);
@ -193,7 +181,7 @@ nlohmann::json LockFile::toJson() const
if (auto lockedNode = std::dynamic_pointer_cast<const LockedNode>(node)) {
n["original"] = fetchers::attrsToJson(lockedNode->originalRef.toAttrs());
n["locked"] = fetchers::attrsToJson(lockedNode->lockedRef.toAttrs());
n["info"] = treeInfoToJson(lockedNode->info);
n["info"] = lockedNode->info.toJson();
if (!lockedNode->isFlake) n["flake"] = false;
}