feat: add inputDrvs to the JSON
Currently, not a lot of things expose inputDrvs (except `show-derivation`), which is a showstopper whenever you want to compute popularity ranking based on the dependency relation. Having `inputsDrvs` in the reply enable downstream users to perform such computations in an efficient way.
This commit is contained in:
parent
a5bb26e9ea
commit
469a68d5c1
|
@ -180,6 +180,7 @@ struct Drv {
|
|||
std::string drvPath;
|
||||
bool isCached;
|
||||
std::map<std::string, std::string> outputs;
|
||||
std::map<std::string, std::set<std::string>> inputDrvs;
|
||||
std::optional<nlohmann::json> meta;
|
||||
|
||||
Drv(EvalState &state, DrvInfo &drvInfo) {
|
||||
|
@ -224,6 +225,11 @@ struct Drv {
|
|||
name = drvInfo.queryName();
|
||||
system = drvInfo.querySystem();
|
||||
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},
|
||||
{"system", drv.system},
|
||||
{"drvPath", drv.drvPath},
|
||||
{"outputs", drv.outputs}};
|
||||
{"outputs", drv.outputs},
|
||||
{"inputDrvs", drv.inputDrvs}};
|
||||
|
||||
if (drv.meta.has_value()) {
|
||||
json["meta"] = drv.meta.value();
|
||||
|
|
Loading…
Reference in a new issue