-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nix log
with CA derivations
#6215
Conversation
@@ -1,15 +1,22 @@ | |||
{ busybox }: | |||
{ busybox, contentAddressed ? false }: | |||
|
|||
with import ./config.nix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall you had rigged this up so that we got a CA or no CA by default mkDerivation
by default?
src/libstore/local-fs-store.cc
Outdated
} else if (settings.isExperimentalFeatureEnabled(Xp::CaDerivations)) { | ||
// The build log is actually attached to the corresponding resolved | ||
// derivation, so we need to get it first | ||
auto drv = readDerivation(path); | ||
auto resolvedDrv = drv.tryResolve(*this); | ||
if (resolvedDrv) | ||
path = writeDerivation(*this, *resolvedDrv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just as we have some foo
and fooUncached
store methods, might we have getBuildLogExact
and getBuildLogResolved
? This logic here isn't specific to this store implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact the !path.isDerivation()
part is also duplicated between the two stores that implement this, too. That could also go in getBuildLogResolved
(or whatever the wrapper function should be called).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually did this intentionnally, because as-it-is, the logic assumes that the derivation is there (we can’t resolve without reading it), so that would break with most binary caches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but can't we just see if the derivation exists and only try resolving it if it does?
This inspired me to split out a |
Did that in #6220. That will help reduce the clutter of a I also noticed the daemon protocol has |
Anyways, I do agree resolving is the right approach. Binary caches should have the trust mappings even if they don't have the drv files for derivations. This means resolving a derivation should not, in fact, require reading the derivation in the happy path (but we can fix that part later). |
beee8e3
to
c735f2e
Compare
Fix #6209 When trying to run `nix log <installable>`, try first to resolve the derivation pointed to by `<installable>` 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.
c735f2e
to
6d49e58
Compare
Thanks! It looks better now, but I would still do std::optional<std::string> LogStore::getBuildLog(const StorePath & path)
{
auto maybePath = getBuildDerivationPath(path);
if (!maybePath)
return std::nullopt;
return getBuildLogExact(maybePath.value())
} where |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-26/18252/1 |
Is this still relevant? |
Yes, still relevant. The linked issue is still not fixed |
What do you think about my |
I would like to separate the concerns of finding the drv vs finding the log. This relates to my hoping we can get rid of |
Not much, will need to find the time to look into it again 😛 |
#7430 was a rebase of this that was merged. |
Fix #6209
When trying to run
nix log <installable>
on a local-fs-store (or indirectly on adaemon or ssh-ng store), try first to resolve the derivation pointed to
by
<installable>
as it is the resolved one that holds the build log.This has a couple of shortcomings:
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:
lot of duplication
long-term solution, but leads to a whole new class of potential
issues.