aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-12-07 15:23:01 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-12-12 14:05:52 +0100
commitfd0ed7511818ba871dc3e28796ec1d0ca57b22ec (patch)
tree75aeee532ba00a2f9a52f472bdcba46969e8a711 /src/libexpr
parentae5f62a894190e0075eb60ae4537ba81ca2a0a8d (diff)
Support flake references in the old CLI
Fixes #7026.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc3
-rw-r--r--src/libexpr/parser.y13
2 files changed, 14 insertions, 2 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index ca8d634da..6955aacbf 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -402,7 +402,8 @@ static Strings parseNixPath(const std::string & s)
}
if (*p == ':') {
- if (EvalSettings::isPseudoUrl(std::string(start2, s.end()))) {
+ auto prefix = std::string(start2, s.end());
+ if (EvalSettings::isPseudoUrl(prefix) || hasPrefix(prefix, "flake:")) {
++p;
while (p != s.end() && *p != ':') ++p;
}
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 6ef9407cd..fbf865719 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -643,6 +643,7 @@ formal
#include "filetransfer.hh"
#include "fetchers.hh"
#include "store-api.hh"
+#include "flake/flake.hh"
namespace nix {
@@ -816,7 +817,17 @@ std::pair<bool, std::string> EvalState::resolveSearchPathElem(const SearchPathEl
});
res = { false, "" };
}
- } else {
+ }
+
+ else if (hasPrefix(elem.second, "flake:")) {
+ settings.requireExperimentalFeature(Xp::Flakes);
+ auto flakeRef = parseFlakeRef(elem.second.substr(6), {}, true, false);
+ debug("fetching flake search path element '%s''", elem.second);
+ auto storePath = flakeRef.resolve(store).fetchTree(store).first.storePath;
+ res = { true, store->toRealPath(storePath) };
+ }
+
+ else {
auto path = absPath(elem.second);
if (pathExists(path))
res = { true, path };