diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index cab7f6c46..42649c98d 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -268,7 +268,6 @@ EvalState::EvalState( std::shared_ptr buildStore) : s(symbols) , repair(NoRepair) - , derivationInternal(CanonPath("/builtin/derivation.nix")) , store(store) , buildStore(buildStore ? buildStore : store) , regexCache(makeRegexCache()) @@ -1331,13 +1330,10 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) state.forceValue(*vCurrent, (posCurrent ? posCurrent : this->pos)); } catch (Error & e) { - if (posCurrent) { - auto pos2r = state.positions[posCurrent]; - auto origin = std::get_if(&pos2r.origin); - if (!(origin && *origin == state.derivationInternal)) - e.addTrace(state.positions[posCurrent], "while evaluating the attribute '%1%'", - showAttrPath(state, env, attrPath)); - } + auto pos2r = state.positions[posCurrent]; + if (pos2r && !std::get_if(&pos2r.origin)) + e.addTrace(pos2r, "while evaluating the attribute '%1%'", + showAttrPath(state, env, attrPath)); throw; } diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index 06e8aee4e..c5beebdbe 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -284,8 +284,6 @@ public: */ std::optional allowedPaths; - const SourcePath derivationInternal; - /** * Store used to materialise .drv files. */ diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index 3934c9ba9..2dce86536 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -2852,7 +2852,7 @@ void EvalState::createBaseEnv() char code[] = #include "primops/derivation.nix.gen.hh" ; - eval(*parse(code, sizeof(code), derivationInternal, {CanonPath::root}, staticBaseEnv), *vDerivation); + eval(*parse(code, sizeof(code), Pos::Hidden{}, {CanonPath::root}, staticBaseEnv), *vDerivation); } diff --git a/lix/libutil/position.cc b/lix/libutil/position.cc index bbeb2e579..cf2ff4b45 100644 --- a/lix/libutil/position.cc +++ b/lix/libutil/position.cc @@ -68,6 +68,9 @@ std::optional Pos::getSource() const } catch (Error &) { return std::nullopt; } + }, + [](Hidden) -> std::optional { + return std::nullopt; } }, origin); } @@ -79,7 +82,8 @@ void Pos::print(std::ostream & out, bool showOrigin) const [&](const std::monostate &) { out << "«none»"; }, [&](const Pos::Stdin &) { out << "«stdin»"; }, [&](const Pos::String & s) { out << "«string»"; }, - [&](const SourcePath & path) { out << path; } + [&](const SourcePath & path) { out << path; }, + [&](Hidden) { out << "«internal»"; }, }, origin); out << ":"; } diff --git a/lix/libutil/position.hh b/lix/libutil/position.hh index 9820ed177..3f89a0f5a 100644 --- a/lix/libutil/position.hh +++ b/lix/libutil/position.hh @@ -38,8 +38,11 @@ struct Pos bool operator<(const String & rhs) const { return *source < *rhs.source; } }; + struct Hidden { + auto operator<=>(const Hidden &) const = default; + }; - typedef std::variant Origin; + typedef std::variant