From 469a68d5c1efb1605f7afd5647c71f6643fa9246 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Mon, 24 Apr 2023 19:33:02 +0200 Subject: [PATCH] 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. --- src/nix-eval-jobs.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nix-eval-jobs.cc b/src/nix-eval-jobs.cc index 49aca05..4f1c6e5 100644 --- a/src/nix-eval-jobs.cc +++ b/src/nix-eval-jobs.cc @@ -180,6 +180,7 @@ struct Drv { std::string drvPath; bool isCached; std::map outputs; + std::map> inputDrvs; std::optional 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();