1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-10-18 00:16:11 -04:00

Tarball fetcher: Handle lock files that *do* contain lastModified

Fixes flake-regressions/tests/DeterminateSystems/eva/0.1.0:

  error: 'lastModified' attribute mismatch in input 'https://api.flakehub.com/f/pinned/ipetkov/crane/0.14.1/018ac45c-ff5e-7076-b956-d478a0336516/source.tar.gz?narHash=sha256-mnE14re43v3/Jc50Jv0BKPMtEk7FEtDSligP6B5HwlI%3D', expected 1695511445
This commit is contained in:
Eelco Dolstra 2024-10-17 16:20:08 +02:00
parent 78b5b4c105
commit 7d1f7f8d59
2 changed files with 9 additions and 7 deletions

View file

@ -220,8 +220,8 @@ void InputScheme::checkLocks(const Input & specified, const Input & final) const
if (auto prevLastModified = specified.getLastModified()) { if (auto prevLastModified = specified.getLastModified()) {
if (final.getLastModified() != prevLastModified) if (final.getLastModified() != prevLastModified)
throw Error("'lastModified' attribute mismatch in input '%s', expected %d", throw Error("'lastModified' attribute mismatch in input '%s', expected %d, got %d",
final.to_string(), *prevLastModified); final.to_string(), *prevLastModified, final.getLastModified().value_or(-1));
} }
if (auto prevRev = specified.getRev()) { if (auto prevRev = specified.getRev()) {

View file

@ -384,11 +384,13 @@ struct TarballInputScheme : CurlInputScheme
input = immutableInput; input = immutableInput;
} }
/* If we got a lastModified and the input is not final and /* If we got a lastModified, then return it. But for
doesn't have one, then return it. Note that we don't do compatibility with old lock files that didn't include
this if the input is final for compatibility with old lock lastModified, don't do this if the original input was final
files that didn't include lastModified. */ and didn't contain a lastModified. */
if (result.lastModified && !_input.isFinal() && !input.attrs.contains("lastModified")) if (result.lastModified
&& !input.attrs.contains("lastModified")
&& (!_input.isFinal() || _input.attrs.contains("lastModified")))
input.attrs.insert_or_assign("lastModified", uint64_t(result.lastModified)); input.attrs.insert_or_assign("lastModified", uint64_t(result.lastModified));
input.attrs.insert_or_assign("narHash", input.attrs.insert_or_assign("narHash",