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

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.
This commit is contained in:
Eelco Dolstra 2024-10-16 15:18:23 +02:00
parent fc09815eda
commit ed1f9dd13f

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));
@ -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)};
}