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

Compare commits

..

2 commits

Author SHA1 Message Date
Eelco Dolstra ed1f9dd13f Don't mark inputs as final in getAccessorUnchecked()
We haven't added the narHash attribute yet at that point. And if the
caller uses getAccesor() instead of fetchToStore() (e.g. in `nix
registry pin`), the narHash attribute will never be added. This could
lead to a mismatch.
2024-10-16 15:18:23 +02:00
Eelco Dolstra fc09815eda
Typo
Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
2024-10-16 15:17:38 +02:00

View file

@ -185,6 +185,14 @@ std::pair<StorePath, Input> Input::fetchToStore(ref<Store> store) const
auto narHash = store->queryPathInfo(storePath)->narHash;
final.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true));
// FIXME: we would like to mark inputs as final in
// getAccessorUnchecked(), but then we can't add
// narHash. Or maybe narHash should be excluded from the
// concept of "final" inputs?
final.attrs.insert_or_assign("final", Explicit<bool>(true));
assert(final.isFinal());
scheme->checkLocks(*this, final);
return {storePath, final};
@ -228,8 +236,6 @@ void InputScheme::checkLocks(const Input & specified, const Input & final) const
final.to_string(), *prevRevCount);
}
assert(final.isFinal());
if (specified.isFinal() && specified.attrs != final.attrs)
throw Error("fetching final input '%s' resulted in different input '%s'",
attrsToJSON(specified.attrs), attrsToJSON(final.attrs));
@ -265,7 +271,7 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
FIXME: add a setting to disable this.
FIXME: substituting may be slower than fetching normally,
e.g. for fetchers like that Git that are incremental!
e.g. for fetchers like Git that are incremental!
*/
if (isFinal() && getNarHash()) {
try {
@ -291,8 +297,6 @@ std::pair<ref<SourceAccessor>, Input> Input::getAccessorUnchecked(ref<Store> sto
assert(!accessor->fingerprint);
accessor->fingerprint = scheme->getFingerprint(store, final);
final.attrs.insert_or_assign("final", Explicit<bool>(true));
return {accessor, std::move(final)};
}