mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
Remove FlakeRef::fetchTree()
This commit is contained in:
parent
1ab97a70f5
commit
c74ad6b32b
4 changed files with 9 additions and 12 deletions
|
@ -34,7 +34,9 @@ EvalSettings evalSettings {
|
||||||
// FIXME `parseFlakeRef` should take a `std::string_view`.
|
// FIXME `parseFlakeRef` should take a `std::string_view`.
|
||||||
auto flakeRef = parseFlakeRef(fetchSettings, std::string { rest }, {}, true, false);
|
auto flakeRef = parseFlakeRef(fetchSettings, std::string { rest }, {}, true, false);
|
||||||
debug("fetching flake search path element '%s''", rest);
|
debug("fetching flake search path element '%s''", rest);
|
||||||
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first;
|
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
|
||||||
|
auto storePath = nix::fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
||||||
|
state.allowPath(storePath);
|
||||||
return state.rootPath(state.store->toRealPath(storePath));
|
return state.rootPath(state.store->toRealPath(storePath));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -183,7 +185,9 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
|
||||||
else if (hasPrefix(s, "flake:")) {
|
else if (hasPrefix(s, "flake:")) {
|
||||||
experimentalFeatureSettings.require(Xp::Flakes);
|
experimentalFeatureSettings.require(Xp::Flakes);
|
||||||
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
|
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
|
||||||
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first;
|
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
|
||||||
|
auto storePath = nix::fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
|
||||||
|
state.allowPath(storePath);
|
||||||
return state.rootPath(CanonPath(state.store->toRealPath(storePath)));
|
return state.rootPath(CanonPath(state.store->toRealPath(storePath)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -283,12 +283,6 @@ FlakeRef FlakeRef::fromAttrs(
|
||||||
fetchers::maybeGetStrAttr(attrs, "dir").value_or(""));
|
fetchers::maybeGetStrAttr(attrs, "dir").value_or(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<StorePath, FlakeRef> FlakeRef::fetchTree(ref<Store> store) const
|
|
||||||
{
|
|
||||||
auto [storePath, lockedInput] = input.fetchToStore(store);
|
|
||||||
return {std::move(storePath), FlakeRef(std::move(lockedInput), subdir)};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, FlakeRef> FlakeRef::lazyFetch(ref<Store> store) const
|
std::pair<ref<SourceAccessor>, FlakeRef> FlakeRef::lazyFetch(ref<Store> store) const
|
||||||
{
|
{
|
||||||
auto [accessor, lockedInput] = input.getAccessor(store);
|
auto [accessor, lockedInput] = input.getAccessor(store);
|
||||||
|
|
|
@ -71,9 +71,6 @@ struct FlakeRef
|
||||||
const fetchers::Settings & fetchSettings,
|
const fetchers::Settings & fetchSettings,
|
||||||
const fetchers::Attrs & attrs);
|
const fetchers::Attrs & attrs);
|
||||||
|
|
||||||
// FIXME: remove
|
|
||||||
std::pair<StorePath, FlakeRef> fetchTree(ref<Store> store) const;
|
|
||||||
|
|
||||||
std::pair<ref<SourceAccessor>, FlakeRef> lazyFetch(ref<Store> store) const;
|
std::pair<ref<SourceAccessor>, FlakeRef> lazyFetch(ref<Store> store) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "eval-cache.hh"
|
#include "eval-cache.hh"
|
||||||
#include "markdown.hh"
|
#include "markdown.hh"
|
||||||
#include "users.hh"
|
#include "users.hh"
|
||||||
|
#include "fetch-to-store.hh"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
@ -1449,7 +1450,8 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON
|
||||||
{
|
{
|
||||||
auto originalRef = getFlakeRef();
|
auto originalRef = getFlakeRef();
|
||||||
auto resolvedRef = originalRef.resolve(store);
|
auto resolvedRef = originalRef.resolve(store);
|
||||||
auto [storePath, lockedRef] = resolvedRef.fetchTree(store);
|
auto [accessor, lockedRef] = resolvedRef.lazyFetch(store);
|
||||||
|
auto storePath = fetchToStore(*store, accessor, FetchMode::Copy, lockedRef.input.getName());
|
||||||
auto hash = store->queryPathInfo(storePath)->narHash;
|
auto hash = store->queryPathInfo(storePath)->narHash;
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue