forked from lix-project/nix-eval-jobs
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;
|
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();
|
||||||
|
|
Loading…
Reference in a new issue