1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 03:23:16 +02:00

Support flake references in the old CLI

Fixes #7026.
This commit is contained in:
Eelco Dolstra 2022-09-13 19:05:05 +02:00
parent 432a3a18d2
commit 2a1c63c785
6 changed files with 113 additions and 44 deletions

View file

@ -405,7 +405,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;
}

View file

@ -637,6 +637,7 @@ formal
#include "fs-input-accessor.hh"
#include "tarball.hh"
#include "store-api.hh"
#include "flake/flake.hh"
namespace nix {
@ -789,13 +790,22 @@ std::optional<SourcePath> EvalState::resolveSearchPathElem(const SearchPathElem
store, EvalSettings::resolvePseudoUrl(elem.second), "source", false).first;
auto accessor = makeStorePathAccessor(store, storePath);
registerAccessor(accessor);
res.emplace(SourcePath {accessor, CanonPath::root});
res.emplace(accessor->root());
} catch (FileTransferError & e) {
logWarning({
.msg = hintfmt("Nix search path entry '%1%' cannot be downloaded, ignoring", elem.second)
});
}
} else {
}
else if (hasPrefix(elem.second, "flake:")) {
auto flakeRef = parseFlakeRef(elem.second.substr(6), {}, true, false);
debug("fetching flake search path element '%s''", elem.second);
auto [accessor, _] = flakeRef.resolve(store).lazyFetch(store);
res.emplace(accessor->root());
}
else {
auto path = rootPath(absPath(elem.second));
/* Allow access to paths in the search path. */