From 04b113f6cb5356d44992f98928a595cdf93d561a Mon Sep 17 00:00:00 2001 From: regnat Date: Tue, 8 Mar 2022 06:02:25 +0100 Subject: Fix `nix log` with CA derivations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #6209 When trying to run `nix log `, try first to resolve the derivation pointed to by `` as it is the resolved one that holds the build log. This has a couple of shortcomings: 1. It’s expensive as it requires re-reading the derivation 2. It’s brittle because if the derivation doesn’t exist anymore or can’t be resolved (which is the case if any one of its build inputs is missing), then we can’t access the log anymore However, I don’t think we can do better (at least not right now). The alternatives I see are: 1. Copy the build log for the un-resolved derivation. But that means a lot of duplication 2. Store the results of the resolving in the db. Which might be the best long-term solution, but leads to a whole new class of potential issues. --- src/libstore/binary-cache-store.cc | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/libstore/binary-cache-store.cc') diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 12d0c32fb..14584f0a2 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -504,18 +504,10 @@ void BinaryCacheStore::addSignatures(const StorePath & storePath, const StringSe std::optional BinaryCacheStore::getBuildLog(const StorePath & path) { - auto drvPath = path; - - if (!path.isDerivation()) { - try { - auto info = queryPathInfo(path); - // FIXME: add a "Log" field to .narinfo - if (!info->deriver) return std::nullopt; - drvPath = *info->deriver; - } catch (InvalidPath &) { - return std::nullopt; - } - } + auto maybePath = getBuildDerivationPath(path); + if (!maybePath) + return std::nullopt; + auto drvPath = maybePath.value(); auto logPath = "log/" + std::string(baseNameOf(printStorePath(drvPath))); -- cgit v1.2.3 From e5eb05c5990d837e0bbc1529e3b5b167f7015be0 Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Thu, 15 Dec 2022 15:58:54 -0500 Subject: getBuildLog: factor out resolving derivations --- src/libstore/binary-cache-store.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/libstore/binary-cache-store.cc') diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index 14584f0a2..0fef2d23a 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -502,14 +502,9 @@ void BinaryCacheStore::addSignatures(const StorePath & storePath, const StringSe writeNarInfo(narInfo); } -std::optional BinaryCacheStore::getBuildLog(const StorePath & path) +std::optional BinaryCacheStore::getBuildLogExact(const StorePath & path) { - auto maybePath = getBuildDerivationPath(path); - if (!maybePath) - return std::nullopt; - auto drvPath = maybePath.value(); - - auto logPath = "log/" + std::string(baseNameOf(printStorePath(drvPath))); + auto logPath = "log/" + std::string(baseNameOf(printStorePath(path))); debug("fetching build log from binary cache '%s/%s'", getUri(), logPath); -- cgit v1.2.3