1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-15 21:41:04 +01:00

Split out UnkeyedRealisation from Realisation

Realisations are conceptually key-value pairs, mapping `DrvOutputs` (the
key) to information about that derivation output.

This separate the value type, which will be useful in maps, etc., where
we don't want to denormalize by including the key twice.

This matches similar changes for existing types:

| keyed              | unkeyed                |
|--------------------|------------------------|
| `ValidPathInfo`    | `UnkeyedValidPathInfo` |
| `KeyedBuildResult` | `BuildResult`          |
| `Realisation`      | `UnkeyedRealisation`   |

Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
John Ericson 2025-09-24 00:06:47 -04:00
parent a543519ca9
commit 6995d325ef
28 changed files with 363 additions and 251 deletions

View file

@ -77,7 +77,7 @@ void LocalOverlayStore::registerDrvOutput(const Realisation & info)
// First do queryRealisation on lower layer to populate DB
auto res = lowerStore->queryRealisation(info.id);
if (res)
LocalStore::registerDrvOutput(*res);
LocalStore::registerDrvOutput({*res, info.id});
LocalStore::registerDrvOutput(info);
}
@ -108,12 +108,12 @@ void LocalOverlayStore::queryPathInfoUncached(
}
void LocalOverlayStore::queryRealisationUncached(
const DrvOutput & drvOutput, Callback<std::shared_ptr<const Realisation>> callback) noexcept
const DrvOutput & drvOutput, Callback<std::shared_ptr<const UnkeyedRealisation>> callback) noexcept
{
auto callbackPtr = std::make_shared<decltype(callback)>(std::move(callback));
LocalStore::queryRealisationUncached(
drvOutput, {[this, drvOutput, callbackPtr](std::future<std::shared_ptr<const Realisation>> fut) {
drvOutput, {[this, drvOutput, callbackPtr](std::future<std::shared_ptr<const UnkeyedRealisation>> fut) {
try {
auto info = fut.get();
if (info)
@ -123,7 +123,7 @@ void LocalOverlayStore::queryRealisationUncached(
}
// If we don't have it, check lower store
lowerStore->queryRealisation(
drvOutput, {[callbackPtr](std::future<std::shared_ptr<const Realisation>> fut) {
drvOutput, {[callbackPtr](std::future<std::shared_ptr<const UnkeyedRealisation>> fut) {
try {
(*callbackPtr)(fut.get());
} catch (...) {