Skip to content

Commit c74ad6b

Browse files
committed
Remove FlakeRef::fetchTree()
1 parent 1ab97a7 commit c74ad6b

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

src/libcmd/common-eval-args.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ EvalSettings evalSettings {
3434
// FIXME `parseFlakeRef` should take a `std::string_view`.
3535
auto flakeRef = parseFlakeRef(fetchSettings, std::string { rest }, {}, true, false);
3636
debug("fetching flake search path element '%s''", rest);
37-
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first;
37+
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
38+
auto storePath = nix::fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
39+
state.allowPath(storePath);
3840
return state.rootPath(state.store->toRealPath(storePath));
3941
},
4042
},
@@ -183,7 +185,9 @@ SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * bas
183185
else if (hasPrefix(s, "flake:")) {
184186
experimentalFeatureSettings.require(Xp::Flakes);
185187
auto flakeRef = parseFlakeRef(fetchSettings, std::string(s.substr(6)), {}, true, false);
186-
auto storePath = flakeRef.resolve(state.store).fetchTree(state.store).first;
188+
auto [accessor, lockedRef] = flakeRef.resolve(state.store).lazyFetch(state.store);
189+
auto storePath = nix::fetchToStore(*state.store, SourcePath(accessor), FetchMode::Copy, lockedRef.input.getName());
190+
state.allowPath(storePath);
187191
return state.rootPath(CanonPath(state.store->toRealPath(storePath)));
188192
}
189193

src/libflake/flake/flakeref.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,6 @@ FlakeRef FlakeRef::fromAttrs(
283283
fetchers::maybeGetStrAttr(attrs, "dir").value_or(""));
284284
}
285285

286-
std::pair<StorePath, FlakeRef> FlakeRef::fetchTree(ref<Store> store) const
287-
{
288-
auto [storePath, lockedInput] = input.fetchToStore(store);
289-
return {std::move(storePath), FlakeRef(std::move(lockedInput), subdir)};
290-
}
291-
292286
std::pair<ref<SourceAccessor>, FlakeRef> FlakeRef::lazyFetch(ref<Store> store) const
293287
{
294288
auto [accessor, lockedInput] = input.getAccessor(store);

src/libflake/flake/flakeref.hh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ struct FlakeRef
7171
const fetchers::Settings & fetchSettings,
7272
const fetchers::Attrs & attrs);
7373

74-
// FIXME: remove
75-
std::pair<StorePath, FlakeRef> fetchTree(ref<Store> store) const;
76-
7774
std::pair<ref<SourceAccessor>, FlakeRef> lazyFetch(ref<Store> store) const;
7875
};
7976

src/nix/flake.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "eval-cache.hh"
1818
#include "markdown.hh"
1919
#include "users.hh"
20+
#include "fetch-to-store.hh"
2021

2122
#include <filesystem>
2223
#include <nlohmann/json.hpp>
@@ -1449,7 +1450,8 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON
14491450
{
14501451
auto originalRef = getFlakeRef();
14511452
auto resolvedRef = originalRef.resolve(store);
1452-
auto [storePath, lockedRef] = resolvedRef.fetchTree(store);
1453+
auto [accessor, lockedRef] = resolvedRef.lazyFetch(store);
1454+
auto storePath = fetchToStore(*store, accessor, FetchMode::Copy, lockedRef.input.getName());
14531455
auto hash = store->queryPathInfo(storePath)->narHash;
14541456

14551457
if (json) {

0 commit comments

Comments
 (0)