diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index a3aeeb55c0..59c42d0b0d 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -639,7 +639,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) state.forceValue(*vAttrs); } catch (Error & e) { - if (pos) + if (pos && pos->file != state.sDerivationNix) addErrorPrefix(e, "while evaluating the attribute `%1%' at %2%:\n", showAttrPath(attrPath), *pos); throw; diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 2f87b9c776..8707182ed1 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -95,6 +95,7 @@ public: const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sSystem, sOverrides, sOutputs, sOutputName, sIgnoreNulls; + Symbol sDerivationNix; /* If set, force copying files to the Nix store even if they already exist there. */ diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index a216fa7abd..0585f5bbe0 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -1262,7 +1262,9 @@ void EvalState::createBaseEnv() /* Add a wrapper around the derivation primop that computes the `drvPath' and `outPath' attributes lazily. */ - evalFile(findFile("nix/derivation.nix"), v); + string path = findFile("nix/derivation.nix"); + sDerivationNix = symbols.create(path); + evalFile(path, v); addConstant("derivation", v); /* Now that we've added all primops, sort the `builtins' attribute