mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
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
).
33 lines
625 B
C++
33 lines
625 B
C++
#pragma once
|
|
|
|
#include "path.hh"
|
|
#include "hash.hh"
|
|
|
|
#include <nlohmann/json_fwd.hpp>
|
|
|
|
namespace nix { class Store; }
|
|
|
|
namespace nix::fetchers {
|
|
|
|
struct TreeInfo
|
|
{
|
|
Hash narHash;
|
|
std::optional<uint64_t> revCount;
|
|
std::optional<time_t> lastModified;
|
|
|
|
bool operator ==(const TreeInfo & other) const
|
|
{
|
|
return
|
|
narHash == other.narHash
|
|
&& revCount == other.revCount
|
|
&& lastModified == other.lastModified;
|
|
}
|
|
|
|
StorePath computeStorePath(Store & store) const;
|
|
|
|
static TreeInfo fromJson(const nlohmann::json & json);
|
|
|
|
nlohmann::json toJson() const;
|
|
};
|
|
|
|
}
|