Merge pull request #207 from RaitoBezarius/input-drvs

feat: add inputDrvs to the JSON
This commit is contained in:
adisbladis 2023-04-26 15:36:28 +12:00 committed by GitHub
commit 73ee1712fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -180,6 +180,7 @@ struct Drv {
std::string drvPath; std::string drvPath;
bool isCached; bool isCached;
std::map<std::string, std::string> outputs; std::map<std::string, std::string> outputs;
std::map<std::string, std::set<std::string>> inputDrvs;
std::optional<nlohmann::json> meta; std::optional<nlohmann::json> meta;
Drv(EvalState &state, DrvInfo &drvInfo) { Drv(EvalState &state, DrvInfo &drvInfo) {
@ -224,6 +225,11 @@ struct Drv {
name = drvInfo.queryName(); name = drvInfo.queryName();
system = drvInfo.querySystem(); system = drvInfo.querySystem();
drvPath = localStore->printStorePath(drvInfo.requireDrvPath()); drvPath = localStore->printStorePath(drvInfo.requireDrvPath());
auto drv = localStore->readDerivation(drvInfo.requireDrvPath());
for (auto &input : drv.inputDrvs) {
inputDrvs[localStore->printStorePath(input.first)] = input.second;
}
} }
}; };
@ -231,7 +237,8 @@ static void to_json(nlohmann::json &json, const Drv &drv) {
json = nlohmann::json{{"name", drv.name}, json = nlohmann::json{{"name", drv.name},
{"system", drv.system}, {"system", drv.system},
{"drvPath", drv.drvPath}, {"drvPath", drv.drvPath},
{"outputs", drv.outputs}}; {"outputs", drv.outputs},
{"inputDrvs", drv.inputDrvs}};
if (drv.meta.has_value()) { if (drv.meta.has_value()) {
json["meta"] = drv.meta.value(); json["meta"] = drv.meta.value();