forked from lix-project/lix
462421d345
This provides a pluggable mechanism for defining new fetchers. It adds
a builtin function 'fetchTree' that generalizes existing fetchers like
'fetchGit', 'fetchMercurial' and 'fetchTarball'. 'fetchTree' takes a
set of attributes, e.g.
fetchTree {
type = "git";
url = "https://example.org/repo.git";
ref = "some-branch";
rev = "abcdef...";
}
The existing fetchers are just wrappers around this. Note that the
input attributes to fetchTree are the same as flake input
specifications and flake lock file entries.
All fetchers share a common cache stored in
~/.cache/nix/fetcher-cache-v1.sqlite. This replaces the ad hoc caching
mechanisms in fetchGit and download.cc (e.g. ~/.cache/nix/{tarballs,git-revs*}).
This also adds support for Git worktrees (c169ea5904
).
35 lines
642 B
C++
35 lines
642 B
C++
#pragma once
|
|
|
|
#include "fetchers.hh"
|
|
|
|
namespace nix::fetchers {
|
|
|
|
struct Cache
|
|
{
|
|
virtual void add(
|
|
ref<Store> store,
|
|
const Attrs & inAttrs,
|
|
const Attrs & infoAttrs,
|
|
const StorePath & storePath,
|
|
bool immutable) = 0;
|
|
|
|
virtual std::optional<std::pair<Attrs, StorePath>> lookup(
|
|
ref<Store> store,
|
|
const Attrs & inAttrs) = 0;
|
|
|
|
struct Result
|
|
{
|
|
bool expired = false;
|
|
Attrs infoAttrs;
|
|
StorePath storePath;
|
|
};
|
|
|
|
virtual std::optional<Result> lookupExpired(
|
|
ref<Store> store,
|
|
const Attrs & inAttrs) = 0;
|
|
};
|
|
|
|
ref<Cache> getCache();
|
|
|
|
}
|