Merge pull request #11041 from hercules-ci/trace-nix-env-attribute-names

getDerivations: add attributes to trace
This commit is contained in:
Eelco Dolstra 2024-07-05 16:32:27 +02:00 committed by GitHub
commit 61e1880847
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -374,21 +374,26 @@ static void getDerivations(EvalState & state, Value & vIn,
bound to the attribute with the "lower" name should take bound to the attribute with the "lower" name should take
precedence). */ precedence). */
for (auto & i : v.attrs()->lexicographicOrder(state.symbols)) { for (auto & i : v.attrs()->lexicographicOrder(state.symbols)) {
debug("evaluating attribute '%1%'", state.symbols[i->name]); try {
if (!std::regex_match(std::string(state.symbols[i->name]), attrRegex)) debug("evaluating attribute '%1%'", state.symbols[i->name]);
continue; if (!std::regex_match(std::string(state.symbols[i->name]), attrRegex))
std::string pathPrefix2 = addToPath(pathPrefix, state.symbols[i->name]); continue;
if (combineChannels) std::string pathPrefix2 = addToPath(pathPrefix, state.symbols[i->name]);
getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures); if (combineChannels)
else if (getDerivation(state, *i->value, pathPrefix2, drvs, done, ignoreAssertionFailures)) { getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
/* If the value of this attribute is itself a set, else if (getDerivation(state, *i->value, pathPrefix2, drvs, done, ignoreAssertionFailures)) {
should we recurse into it? => Only if it has a /* If the value of this attribute is itself a set,
`recurseForDerivations = true' attribute. */ should we recurse into it? => Only if it has a
if (i->value->type() == nAttrs) { `recurseForDerivations = true' attribute. */
auto j = i->value->attrs()->get(state.sRecurseForDerivations); if (i->value->type() == nAttrs) {
if (j && state.forceBool(*j->value, j->pos, "while evaluating the attribute `recurseForDerivations`")) auto j = i->value->attrs()->get(state.sRecurseForDerivations);
getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures); if (j && state.forceBool(*j->value, j->pos, "while evaluating the attribute `recurseForDerivations`"))
getDerivations(state, *i->value, pathPrefix2, autoArgs, drvs, done, ignoreAssertionFailures);
}
} }
} catch (Error & e) {
e.addTrace(state.positions[i->pos], "while evaluating the attribute '%s'", state.symbols[i->name]);
throw;
} }
} }
} }