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

Don't use DerivedPath::toJSON()

It doesn't work on unrealized paths.
This commit is contained in:
Eelco Dolstra 2025-03-14 17:05:38 +01:00
parent 762114b7c4
commit fd0d824fa5
4 changed files with 22 additions and 12 deletions

View file

@ -23,11 +23,20 @@ void to_json(nlohmann::json & json, const BuildResult & buildResult)
json["stopTime"] = buildResult.stopTime;
}
nlohmann::json KeyedBuildResult::toJSON(Store & store) const
void to_json(nlohmann::json & json, const KeyedBuildResult & buildResult)
{
auto json = nlohmann::json((const BuildResult &) *this);
json["path"] = path.toJSON(store);
return json;
to_json(json, (const BuildResult &) buildResult);
auto path = nlohmann::json::object();
std::visit(
overloaded{
[&](const DerivedPathOpaque & opaque) { path["opaque"] = opaque.path.to_string(); },
[&](const DerivedPathBuilt & drv) {
path["drvPath"] = drv.drvPath->getBaseStorePath().to_string();
path["outputs"] = drv.outputs.to_string();
},
},
buildResult.path.raw());
json["path"] = std::move(path);
}
}