aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/derivation-goal.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-10-08 17:36:51 +0200
committerregnat <rg@regnat.ovh>2020-12-11 20:41:32 +0100
commit58cdab64acd4807f73768fb32acdde39b501799f (patch)
tree6e68a9f51e1a43d59d4e56ba58c0de6149662f7f /src/libstore/build/derivation-goal.cc
parent9c143c411b2190a05907416266b0022e5b17dd02 (diff)
Store metadata about drv outputs realisations
For each known realisation, store: - its output - its output path This comes with a set of needed changes: - New `realisations` module declaring the types needed for describing these mappings - New `Store::registerDrvOutput` method registering all the needed informations about a derivation output (also replaces `LocalStore::linkDeriverToPath`) - new `Store::queryRealisation` method to retrieve the informations for a derivations This introcudes some redundancy on the remote-store side between `wopQueryDerivationOutputMap` and `wopQueryRealisation`. However we might need to keep both (regardless of backwards compat) because we sometimes need to get some infos for all the outputs of a derivation (where `wopQueryDerivationOutputMap` is handy), but all the stores can't implement it − because listing all the outputs of a derivation isn't really possible for binary caches where the server doesn't allow to list a directory.
Diffstat (limited to 'src/libstore/build/derivation-goal.cc')
-rw-r--r--src/libstore/build/derivation-goal.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index de58d9f06..a0f10c33d 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -2094,6 +2094,20 @@ struct RestrictedStore : public LocalFSStore, public virtual RestrictedStoreConf
/* Nothing to be done; 'path' must already be valid. */
}
+ void registerDrvOutput(const Realisation & info) override
+ {
+ if (!goal.isAllowed(info.id.drvPath))
+ throw InvalidPath("cannot register unknown drv output '%s' in recursive Nix", printStorePath(info.id.drvPath));
+ next->registerDrvOutput(info);
+ }
+
+ std::optional<const Realisation> queryRealisation(const DrvOutput & id) override
+ {
+ if (!goal.isAllowed(id.drvPath))
+ throw InvalidPath("cannot query the output info for unknown derivation '%s' in recursive Nix", printStorePath(id.drvPath));
+ return next->queryRealisation(id);
+ }
+
void buildPaths(const std::vector<StorePathWithOutputs> & paths, BuildMode buildMode) override
{
if (buildMode != bmNormal) throw Error("unsupported build mode");
@@ -3393,7 +3407,10 @@ void DerivationGoal::registerOutputs()
if (useDerivation || isCaFloating)
for (auto & [outputName, newInfo] : infos)
- worker.store.linkDeriverToPath(drvPathResolved, outputName, newInfo.path);
+ worker.store.registerDrvOutput(
+ DrvOutputId{drvPathResolved, outputName},
+ DrvOutputInfo{.outPath = newInfo.path,
+ .resolvedDrv = drvPathResolved});
}