mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-19 09:36:47 +02:00
getDerivations: add attributes to trace
This improves the error message of nix-env -qa, among others, which is crucial for understanding some ofborg eval error reports, such as https://gist.github.com/GrahamcOfBorg/89101ca9c2c855d288178f1d3c78efef After this change, it will report the same trace, but also start with ``` error: … while evaluating the attribute 'devShellTools' … while evaluating the attribute 'nixos' … while evaluating the attribute 'docker-tools-nix-shell' … while evaluating the attribute 'aarch64-darwin' … from call site at /home/user/h/nixpkgs/outpaths.nix:48:6: 47| tweak = lib.mapAttrs 48| (name: val: | ^ 49| if name == "recurseForDerivations" then true <same> ```
This commit is contained in:
parent
509be0e77a
commit
09763c7cad
1 changed files with 19 additions and 14 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue