aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 8811ab578..ebd641aa4 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -1300,6 +1300,34 @@ Derivation readDerivationCommon(Store& store, const StorePath& drvPath, bool req
}
}
+std::optional<StorePath> Store::getBuildDerivationPath(const StorePath & path)
+{
+
+ if (!path.isDerivation()) {
+ try {
+ auto info = queryPathInfo(path);
+ if (!info->deriver) return std::nullopt;
+ return *info->deriver;
+ } catch (InvalidPath &) {
+ return std::nullopt;
+ }
+ }
+
+ if (!settings.isExperimentalFeatureEnabled(Xp::CaDerivations) || !isValidPath(path))
+ return path;
+
+ auto drv = readDerivation(path);
+ if (!derivationHasKnownOutputPaths(drv.type())) {
+ // The build log is actually attached to the corresponding
+ // resolved derivation, so we need to get it first
+ auto resolvedDrv = drv.tryResolve(*this);
+ if (resolvedDrv)
+ return writeDerivation(*this, *resolvedDrv, NoRepair, true);
+ }
+
+ return path;
+}
+
Derivation Store::readDerivation(const StorePath & drvPath)
{ return readDerivationCommon(*this, drvPath, true); }