diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-12-07 15:23:01 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-12-12 14:05:52 +0100 |
commit | fd0ed7511818ba871dc3e28796ec1d0ca57b22ec (patch) | |
tree | 75aeee532ba00a2f9a52f472bdcba46969e8a711 /src/libcmd/common-eval-args.cc | |
parent | ae5f62a894190e0075eb60ae4537ba81ca2a0a8d (diff) |
Support flake references in the old CLI
Fixes #7026.
Diffstat (limited to 'src/libcmd/common-eval-args.cc')
-rw-r--r-- | src/libcmd/common-eval-args.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libcmd/common-eval-args.cc b/src/libcmd/common-eval-args.cc index 782a25964..64be2629b 100644 --- a/src/libcmd/common-eval-args.cc +++ b/src/libcmd/common-eval-args.cc @@ -146,10 +146,21 @@ Path lookupFileArg(EvalState & state, std::string_view s) auto storePath = fetchers::downloadTarball( state.store, EvalSettings::resolvePseudoUrl(s), "source", false).first.storePath; return state.store->toRealPath(storePath); - } else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { + } + + else if (hasPrefix(s, "flake:")) { + settings.requireExperimentalFeature(Xp::Flakes); + auto flakeRef = parseFlakeRef(std::string(s.substr(6)), {}, true, false); + auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first.storePath; + return state.store->toRealPath(storePath); + } + + else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { Path p(s.substr(1, s.size() - 2)); return state.findFile(p); - } else + } + + else return absPath(std::string(s)); } |