aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-07-21 08:53:18 -0400
committerGitHub <noreply@github.com>2023-07-21 08:53:18 -0400
commitfe1fbdb5a14a059763fcc7434f2cd1e483dc00e6 (patch)
tree74b640a70e98095ac912c9fa822737b90e88ec71 /src/libstore/store-api.cc
parent7ac24d952545637b6af2d60852bdd2750621b504 (diff)
parent6bc98c7fba9f783414692fcef41d90ed80928b6c (diff)
Merge pull request #8724 from obsidiansystems/queryPartialDerivationOutputMap-evalStore
Give `queryPartialDerivationOutputMap` an `evalStore` parameter
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index b16f5a6b7..4ea16a1c0 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -492,22 +492,50 @@ bool Store::PathInfoCacheValue::isKnownNow()
return std::chrono::steady_clock::now() < time_point + ttl;
}
-std::map<std::string, std::optional<StorePath>> Store::queryPartialDerivationOutputMap(const StorePath & path)
+std::map<std::string, std::optional<StorePath>> Store::queryStaticPartialDerivationOutputMap(const StorePath & path)
{
std::map<std::string, std::optional<StorePath>> outputs;
auto drv = readInvalidDerivation(path);
- for (auto& [outputName, output] : drv.outputsAndOptPaths(*this)) {
+ for (auto & [outputName, output] : drv.outputsAndOptPaths(*this)) {
outputs.emplace(outputName, output.second);
}
return outputs;
}
+std::map<std::string, std::optional<StorePath>> Store::queryPartialDerivationOutputMap(
+ const StorePath & path,
+ Store * evalStore_)
+{
+ auto & evalStore = evalStore_ ? *evalStore_ : *this;
+
+ auto outputs = evalStore.queryStaticPartialDerivationOutputMap(path);
+
+ if (!experimentalFeatureSettings.isEnabled(Xp::CaDerivations))
+ return outputs;
+
+ auto drv = evalStore.readInvalidDerivation(path);
+ auto drvHashes = staticOutputHashes(*this, drv);
+ for (auto & [outputName, hash] : drvHashes) {
+ auto realisation = queryRealisation(DrvOutput{hash, outputName});
+ if (realisation) {
+ outputs.insert_or_assign(outputName, realisation->outPath);
+ } else {
+ // queryStaticPartialDerivationOutputMap is not guaranteed
+ // to return std::nullopt for outputs which are not
+ // statically known.
+ outputs.insert({outputName, std::nullopt});
+ }
+ }
+
+ return outputs;
+}
+
OutputPathMap Store::queryDerivationOutputMap(const StorePath & path) {
auto resp = queryPartialDerivationOutputMap(path);
OutputPathMap result;
for (auto & [outName, optOutPath] : resp) {
if (!optOutPath)
- throw Error("output '%s' of derivation '%s' has no store path mapped to it", outName, printStorePath(path));
+ throw MissingRealisation(printStorePath(path), outName);
result.insert_or_assign(outName, *optOutPath);
}
return result;