diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/attr-path.cc | 9 | ||||
-rw-r--r-- | src/libexpr/attr-path.hh | 2 | ||||
-rwxr-xr-x | src/nix-build/nix-build.cc | 2 | ||||
-rw-r--r-- | src/nix-env/nix-env.cc | 4 | ||||
-rw-r--r-- | src/nix-instantiate/nix-instantiate.cc | 2 | ||||
-rw-r--r-- | src/nix-prefetch-url/nix-prefetch-url.cc | 2 | ||||
-rw-r--r-- | src/nix/flake.cc | 2 | ||||
-rw-r--r-- | src/nix/installables.cc | 6 | ||||
-rw-r--r-- | src/nix/upgrade-nix.cc | 2 |
9 files changed, 17 insertions, 14 deletions
diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc index 843585631..1e22f5708 100644 --- a/src/libexpr/attr-path.cc +++ b/src/libexpr/attr-path.cc @@ -32,7 +32,7 @@ static Strings parseAttrPath(const string & s) } -Value * findAlongAttrPath(EvalState & state, const string & attrPath, +std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attrPath, Bindings & autoArgs, Value & vIn) { Strings tokens = parseAttrPath(attrPath); @@ -41,6 +41,7 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath, Error(format("attribute selection path '%1%' does not match expression") % attrPath); Value * v = &vIn; + Pos pos = noPos; for (auto & attr : tokens) { @@ -72,6 +73,7 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath, if (a == v->attrs->end()) throw AttrPathNotFound("attribute '%1%' in selection path '%2%' not found", attr, attrPath); v = &*a->value; + pos = *a->pos; } else if (apType == apIndex) { @@ -85,11 +87,12 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath, throw AttrPathNotFound("list index %1% in selection path '%2%' is out of range", attrIndex, attrPath); v = v->listElems()[attrIndex]; + pos = noPos; } } - return v; + return {v, pos}; } @@ -98,7 +101,7 @@ Pos findDerivationFilename(EvalState & state, Value & v, std::string what) Value * v2; try { auto dummyArgs = state.allocBindings(0); - v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v); + v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v).first; } catch (Error &) { throw Error("package '%s' has no source location information", what); } diff --git a/src/libexpr/attr-path.hh b/src/libexpr/attr-path.hh index fcccc39c8..3e78e2899 100644 --- a/src/libexpr/attr-path.hh +++ b/src/libexpr/attr-path.hh @@ -9,7 +9,7 @@ namespace nix { MakeError(AttrPathNotFound, Error); -Value * findAlongAttrPath(EvalState & state, const string & attrPath, +std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attrPath, Bindings & autoArgs, Value & vIn); /* Heuristic to find the filename and lineno or a nix value. */ diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 205165a4c..d22767967 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -309,7 +309,7 @@ static void _main(int argc, char * * argv) state->eval(e, vRoot); for (auto & i : attrPaths) { - Value & v(*findAlongAttrPath(*state, i, *autoArgs, vRoot)); + Value & v(*findAlongAttrPath(*state, i, *autoArgs, vRoot).first); state->forceValue(v); getDerivations(*state, v, "", *autoArgs, drvs, false); } diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 03503eab1..5ef8cb989 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -178,7 +178,7 @@ static void loadDerivations(EvalState & state, Path nixExprPath, Value vRoot; loadSourceExpr(state, nixExprPath, vRoot); - Value & v(*findAlongAttrPath(state, pathPrefix, autoArgs, vRoot)); + Value & v(*findAlongAttrPath(state, pathPrefix, autoArgs, vRoot).first); getDerivations(state, v, pathPrefix, autoArgs, elems, true); @@ -408,7 +408,7 @@ static void queryInstSources(EvalState & state, Value vRoot; loadSourceExpr(state, instSource.nixExprPath, vRoot); for (auto & i : args) { - Value & v(*findAlongAttrPath(state, i, *instSource.autoArgs, vRoot)); + Value & v(*findAlongAttrPath(state, i, *instSource.autoArgs, vRoot).first); getDerivations(state, v, "", *instSource.autoArgs, elems, true); } break; diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index 5a886d69d..617d927a4 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -39,7 +39,7 @@ void processExpr(EvalState & state, const Strings & attrPaths, state.eval(e, vRoot); for (auto & i : attrPaths) { - Value & v(*findAlongAttrPath(state, i, autoArgs, vRoot)); + Value & v(*findAlongAttrPath(state, i, autoArgs, vRoot).first); state.forceValue(v); PathSet context; diff --git a/src/nix-prefetch-url/nix-prefetch-url.cc b/src/nix-prefetch-url/nix-prefetch-url.cc index cc0891811..18ced94b1 100644 --- a/src/nix-prefetch-url/nix-prefetch-url.cc +++ b/src/nix-prefetch-url/nix-prefetch-url.cc @@ -120,7 +120,7 @@ static int _main(int argc, char * * argv) Path path = resolveExprPath(lookupFileArg(*state, args.empty() ? "." : args[0])); Value vRoot; state->evalFile(path, vRoot); - Value & v(*findAlongAttrPath(*state, attrPath, autoArgs, vRoot)); + Value & v(*findAlongAttrPath(*state, attrPath, autoArgs, vRoot).first); state->forceAttrs(v); /* Extract the URI. */ diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 3b473de73..8945d8829 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -348,7 +348,7 @@ struct CmdFlakeCheck : FlakeCommand Activity act(*logger, lvlChatty, actUnknown, fmt("checking NixOS configuration '%s'", attrPath)); Bindings & bindings(*state->allocBindings(0)); - auto vToplevel = findAlongAttrPath(*state, "config.system.build.toplevel", bindings, v); + auto vToplevel = findAlongAttrPath(*state, "config.system.build.toplevel", bindings, v).first; state->forceAttrs(*vToplevel, pos); if (!state->isDerivation(*vToplevel)) throw Error("attribute 'config.system.build.toplevel' is not a derivation"); diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 752a1466f..fc9c8ab45 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -250,7 +250,7 @@ struct InstallableAttrPath : InstallableValue Value * toValue(EvalState & state) override { - auto vRes = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), *v); + auto vRes = findAlongAttrPath(state, attrPath, *cmd.getAutoArgs(state), *v).first; state.forceValue(*vRes); return vRes; } @@ -360,7 +360,7 @@ std::tuple<std::string, FlakeRef, flake::EvalCache::Derivation> InstallableFlake vOutputs = getFlakeOutputs(*state, lockedFlake); try { - auto * v = findAlongAttrPath(*state, attrPath, *emptyArgs, *vOutputs); + auto * v = findAlongAttrPath(*state, attrPath, *emptyArgs, *vOutputs).first; state->forceValue(*v); auto drvInfo = getDerivation(*state, *v, false); @@ -401,7 +401,7 @@ Value * InstallableFlake::toValue(EvalState & state) for (auto & attrPath : getActualAttrPaths()) { try { - auto * v = findAlongAttrPath(state, attrPath, *emptyArgs, *vOutputs); + auto * v = findAlongAttrPath(state, attrPath, *emptyArgs, *vOutputs).first; state.forceValue(*v); return v; } catch (AttrPathNotFound & e) { diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc index 87f1f9d1b..c05c29517 100644 --- a/src/nix/upgrade-nix.cc +++ b/src/nix/upgrade-nix.cc @@ -145,7 +145,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand auto v = state->allocValue(); state->eval(state->parseExprFromString(*res.data, "/no-such-path"), *v); Bindings & bindings(*state->allocBindings(0)); - auto v2 = findAlongAttrPath(*state, settings.thisSystem, bindings, *v); + auto v2 = findAlongAttrPath(*state, settings.thisSystem, bindings, *v).first; return store->parseStorePath(state->forceString(*v2)); } |