aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-04-14 14:04:19 +0200
committerEelco Dolstra <edolstra@gmail.com>2022-04-14 14:07:04 +0200
commitd89840b103e57e81e5245c3fe9edfbf7c3477ad5 (patch)
tree2b4058e6b37f4b164ae84c89a2a25189b02ccd49 /src/nix
parent0e58affd3967d113e43811311db9ee090778a756 (diff)
Make InstallableFlake::toValue() and toDerivation() behave consistently
In particular, this means that 'nix eval` (which uses toValue()) no longer auto-calls functions or functors (because AttrCursor::findAlongAttrPath() doesn't). Fixes #6152. Also use ref<> in a few places, and don't return attrpaths from getCursor() because cursors already have a getAttrPath() method.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/app.cc4
-rw-r--r--src/nix/flake.cc2
-rw-r--r--src/nix/search.cc4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/nix/app.cc b/src/nix/app.cc
index 803d028f0..55efccdee 100644
--- a/src/nix/app.cc
+++ b/src/nix/app.cc
@@ -61,7 +61,7 @@ std::string resolveString(Store & store, const std::string & toResolve, const Bu
UnresolvedApp Installable::toApp(EvalState & state)
{
- auto [cursor, attrPath] = getCursor(state);
+ auto cursor = getCursor(state);
auto type = cursor->getAttr("type")->getString();
@@ -101,7 +101,7 @@ UnresolvedApp Installable::toApp(EvalState & state)
}
else
- throw Error("attribute '%s' has unsupported type '%s'", attrPath, type);
+ throw Error("attribute '%s' has unsupported type '%s'", cursor->getAttrPathStr(), type);
}
// FIXME: move to libcmd
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index a876bb3af..66c315e5a 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -705,7 +705,7 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
defaultTemplateAttrPathsPrefixes,
lockFlags);
- auto [cursor, attrPath] = installable.getCursor(*evalState);
+ auto cursor = installable.getCursor(*evalState);
auto templateDirAttr = cursor->getAttr("path");
auto templateDir = templateDirAttr->getString();
diff --git a/src/nix/search.cc b/src/nix/search.cc
index e9307342c..e96a85ea2 100644
--- a/src/nix/search.cc
+++ b/src/nix/search.cc
@@ -165,8 +165,8 @@ struct CmdSearch : InstallableCommand, MixJSON
}
};
- for (auto & [cursor, prefix] : installable->getCursors(*state))
- visit(*cursor, parseAttrPath(*state, prefix), true);
+ for (auto & cursor : installable->getCursors(*state))
+ visit(*cursor, cursor->getAttrPath(), true);
if (!json && !results)
throw Error("no results for the given search term(s)!");