libstore: asyncify Store::getBuildDerivationPath

Change-Id: Ie9c41eab4bfa548aa19f6587d60d9c0250ef2f54
This commit is contained in:
eldritch horrors
2025-02-10 12:54:19 +00:00
parent 3b1ade4b32
commit e19a1a25e8
3 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ namespace nix {
kj::Promise<Result<std::optional<std::string>>> LogStore::getBuildLog(const StorePath & path)
try {
auto maybePath = getBuildDerivationPath(path);
auto maybePath = TRY_AWAIT(getBuildDerivationPath(path));
if (!maybePath)
co_return std::nullopt;
co_return getBuildLogExact(maybePath.value());
+9 -7
View File
@@ -1412,20 +1412,20 @@ Derivation readDerivationCommon(Store& store, const StorePath& drvPath, bool req
}
}
std::optional<StorePath> Store::getBuildDerivationPath(const StorePath & path)
{
kj::Promise<Result<std::optional<StorePath>>> Store::getBuildDerivationPath(const StorePath & path)
try {
if (!path.isDerivation()) {
try {
auto info = queryPathInfo(path);
return info->deriver;
co_return info->deriver;
} catch (InvalidPath &) {
return std::nullopt;
co_return std::nullopt;
}
}
if (!experimentalFeatureSettings.isEnabled(Xp::CaDerivations) || !isValidPath(path))
return path;
co_return path;
auto drv = readDerivation(path);
if (!drv.type().hasKnownOutputPaths()) {
@@ -1433,10 +1433,12 @@ std::optional<StorePath> Store::getBuildDerivationPath(const StorePath & path)
// resolved derivation, so we need to get it first
auto resolvedDrv = drv.tryResolve(*this);
if (resolvedDrv)
return writeDerivation(*this, *resolvedDrv, NoRepair, true);
co_return writeDerivation(*this, *resolvedDrv, NoRepair, true);
}
return path;
co_return path;
} catch (...) {
co_return result::current_exception();
}
Derivation Store::readDerivation(const StorePath & drvPath)
+1 -1
View File
@@ -831,7 +831,7 @@ public:
* - If the path is a content-addressed derivation, try to resolve it
* - Otherwise, find one of its derivers
*/
std::optional<StorePath> getBuildDerivationPath(const StorePath &);
kj::Promise<Result<std::optional<StorePath>>> getBuildDerivationPath(const StorePath &);
/**
* Hack to allow long-running processes like hydra-queue-runner to