1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-03 07:31:00 +01:00

Merge pull request #11020 from DeterminateSystems/fix-tarball-caching

Tarball fetcher: Fix fetchToStore() and eval caching
This commit is contained in:
Eelco Dolstra 2024-07-05 16:30:12 +02:00 committed by GitHub
commit e1b6b3ce27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 2 deletions

View file

@ -260,6 +260,7 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
auto [accessor, final] = scheme->getAccessor(store, *this);
assert(!accessor->fingerprint);
accessor->fingerprint = scheme->getFingerprint(store, final);
return {accessor, std::move(final)};
@ -418,7 +419,7 @@ namespace nlohmann {
using namespace nix;
fetchers::PublicKey adl_serializer<fetchers::PublicKey>::from_json(const json & json) {
fetchers::PublicKey res = { };
fetchers::PublicKey res = { };
if (auto type = optionalValueAt(json, "type"))
res.type = getString(*type);

View file

@ -365,6 +365,16 @@ struct TarballInputScheme : CurlInputScheme
return {result.accessor, input};
}
std::optional<std::string> getFingerprint(ref<Store> store, const Input & input) const override
{
if (auto narHash = input.getNarHash())
return narHash->to_string(HashFormat::SRI, true);
else if (auto rev = input.getRev())
return rev->gitRev();
else
return std::nullopt;
}
};
static auto rTarballInputScheme = OnStartup([] { registerInputScheme(std::make_unique<TarballInputScheme>()); });