Add support for recurseForDerivations
This will respect `recurseForDerivations` when iterating over attrsets.
Example expression:
``` nix
{ system ? builtins.currentSystem }:
{
recurseForDerivations = true;
# This should build as it's in the top-level attrset
drvA = derivation {
inherit system;
name = "drvA";
builder = ":";
};
dontRecurse = {
# This shouldn't build as `recurseForDerivations = true;` is not set
# recurseForDerivations = true;
# This should not build
drvB = derivation {
inherit system;
name = "drvA";
builder = ":";
};
};
recurse = {
# This should build
recurseForDerivations = true;
# This should not build
drvC = derivation {
inherit system;
name = "drvC";
builder = ":";
};
};
}
```
This commit is contained in:
+11
-2
@@ -281,7 +281,8 @@ static void worker(
|
||||
else if (v->type() == nAttrs)
|
||||
{
|
||||
auto attrs = nlohmann::json::array();
|
||||
StringSet ss;
|
||||
bool recurse = attrPath == ""; // Dont require `recurseForDerivations = true;` for top-level attrset
|
||||
|
||||
for (auto & i : v->attrs->lexicographicOrder()) {
|
||||
std::string name(i->name);
|
||||
if (name.find('.') != std::string::npos || name.find(' ') != std::string::npos) {
|
||||
@@ -289,8 +290,16 @@ static void worker(
|
||||
continue;
|
||||
}
|
||||
attrs.push_back(name);
|
||||
|
||||
if (name == "recurseForDerivations") {
|
||||
auto attrv = v->attrs->get(state.sRecurseForDerivations);
|
||||
recurse = state.forceBool(*attrv->value, *attrv->pos);
|
||||
}
|
||||
}
|
||||
reply["attrs"] = std::move(attrs);
|
||||
if (recurse)
|
||||
reply["attrs"] = std::move(attrs);
|
||||
else
|
||||
reply["attrs"] = nlohmann::json::array();
|
||||
}
|
||||
|
||||
else if (v->type() == nNull)
|
||||
|
||||
Reference in New Issue
Block a user