mirror of
https://github.com/NixOS/nix.git
synced 2025-11-30 14:10:59 +01:00
GitArchiveInputScheme: Bring back the narHash attribute
This is needed to verify that the source tree served by GitHub hasn't changed compared to the lock file. Computing the narHash for a nixpkgs source tree only takes ~0.6s and it's cached. So the cost is fairly negligible compared to the download time.
This commit is contained in:
parent
8342317d4d
commit
4072024d79
3 changed files with 35 additions and 0 deletions
|
|
@ -220,6 +220,25 @@ struct GitArchiveInputScheme : InputScheme
|
|||
|
||||
auto accessor = makeZipInputAccessor(CanonPath(store->toRealPath(storePath)));
|
||||
|
||||
/* Compute the NAR hash of the contents of the zip file. This
|
||||
is checked against the NAR hash in the lock file in
|
||||
Input::checkLocks(). */
|
||||
auto key = fmt("zip-nar-hash-%s", store->toRealPath(storePath.to_string()));
|
||||
|
||||
auto cache = getCache();
|
||||
|
||||
auto narHash = [&]() {
|
||||
if (auto narHashS = cache->queryFact(key)) {
|
||||
return Hash::parseSRI(*narHashS);
|
||||
} else {
|
||||
auto narHash = accessor->hashPath(CanonPath::root);
|
||||
cache->upsertFact(key, narHash.to_string(SRI, true));
|
||||
return narHash;
|
||||
}
|
||||
}();
|
||||
|
||||
input2.attrs.insert_or_assign("narHash", narHash.to_string(SRI, true));
|
||||
|
||||
auto lastModified = accessor->getLastModified();
|
||||
assert(lastModified);
|
||||
input2.attrs.insert_or_assign("lastModified", uint64_t(*lastModified));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue