mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
Remove FlakeRef::fetchTree()
This commit is contained in:
parent
022390af5a
commit
e7faf65784
4 changed files with 6 additions and 23 deletions
|
@ -229,12 +229,6 @@ FlakeRef FlakeRef::fromAttrs(const fetchers::Attrs & attrs)
|
||||||
fetchers::maybeGetStrAttr(attrs, "dir").value_or(""));
|
fetchers::maybeGetStrAttr(attrs, "dir").value_or(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<fetchers::Tree, FlakeRef> FlakeRef::fetchTree(ref<Store> store) const
|
|
||||||
{
|
|
||||||
auto [tree, lockedInput] = input.fetch(store);
|
|
||||||
return {std::move(tree), FlakeRef(std::move(lockedInput), subdir)};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<ref<InputAccessor>, FlakeRef> FlakeRef::lazyFetch(ref<Store> store) const
|
std::pair<ref<InputAccessor>, FlakeRef> FlakeRef::lazyFetch(ref<Store> store) const
|
||||||
{
|
{
|
||||||
auto [accessor, lockedInput] = input.lazyFetch(store);
|
auto [accessor, lockedInput] = input.lazyFetch(store);
|
||||||
|
|
|
@ -57,8 +57,6 @@ struct FlakeRef
|
||||||
|
|
||||||
static FlakeRef fromAttrs(const fetchers::Attrs & attrs);
|
static FlakeRef fromAttrs(const fetchers::Attrs & attrs);
|
||||||
|
|
||||||
std::pair<fetchers::Tree, FlakeRef> fetchTree(ref<Store> store) const;
|
|
||||||
|
|
||||||
std::pair<ref<InputAccessor>, FlakeRef> lazyFetch(ref<Store> store) const;
|
std::pair<ref<InputAccessor>, FlakeRef> lazyFetch(ref<Store> store) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,18 @@ R""(
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
* Download a tarball and unpack it:
|
* Download a tarball:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# nix flake prefetch https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.5.tar.xz
|
# nix flake prefetch https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.5.tar.xz
|
||||||
Downloaded 'https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.5.tar.xz?narHash=sha256-3XYHZANT6AFBV0BqegkAZHbba6oeDkIUCDwbATLMhAY='
|
Fetched 'https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.5.tar.xz?narHash=sha256-3XYHZANT6AFBV0BqegkAZHbba6oeDkIUCDwbATLMhAY='.
|
||||||
to '/nix/store/sl5vvk8mb4ma1sjyy03kwpvkz50hd22d-source' (hash
|
|
||||||
'sha256-3XYHZANT6AFBV0BqegkAZHbba6oeDkIUCDwbATLMhAY=').
|
|
||||||
```
|
```
|
||||||
|
|
||||||
* Download the `dwarffs` flake (looked up in the flake registry):
|
* Download the `dwarffs` flake (looked up in the flake registry):
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# nix flake prefetch dwarffs --json
|
# nix flake prefetch dwarffs --json
|
||||||
{"hash":"sha256-VHg3MYVgQ12LeRSU2PSoDeKlSPD8PYYEFxxwkVVDRd0="
|
{}
|
||||||
,"storePath":"/nix/store/hang3792qwdmm2n0d9nsrs5n6bsws6kv-source"}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
|
|
@ -1163,7 +1163,7 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON
|
||||||
|
|
||||||
std::string description() override
|
std::string description() override
|
||||||
{
|
{
|
||||||
return "download the source tree denoted by a flake reference into the Nix store";
|
return "fetch the source tree denoted by a flake reference";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string doc() override
|
std::string doc() override
|
||||||
|
@ -1177,19 +1177,13 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON
|
||||||
{
|
{
|
||||||
auto originalRef = getFlakeRef();
|
auto originalRef = getFlakeRef();
|
||||||
auto resolvedRef = originalRef.resolve(store);
|
auto resolvedRef = originalRef.resolve(store);
|
||||||
auto [tree, lockedRef] = resolvedRef.fetchTree(store);
|
auto [accessor, lockedRef] = resolvedRef.lazyFetch(store);
|
||||||
auto hash = store->queryPathInfo(tree.storePath)->narHash;
|
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
auto res = nlohmann::json::object();
|
auto res = nlohmann::json::object();
|
||||||
res["storePath"] = store->printStorePath(tree.storePath);
|
|
||||||
res["hash"] = hash.to_string(SRI, true);
|
|
||||||
logger->cout(res.dump());
|
logger->cout(res.dump());
|
||||||
} else {
|
} else {
|
||||||
notice("Downloaded '%s' to '%s' (hash '%s').",
|
notice("Fetched '%s'.", lockedRef.to_string());
|
||||||
lockedRef.to_string(),
|
|
||||||
store->printStorePath(tree.storePath),
|
|
||||||
hash.to_string(SRI, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue