Skip to content
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 building CA derivations with and eval store #9589

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Dec 11, 2023

Motivation

Fix the bug! Add the test!

Context

I don't love the way this code looks. There are two larger problems:

  • eval, build/scratch, destination stores (Separate stores for evaluation, building and storing the result #5025) should have different types to
    reflect the fact that they are used for different purposes and those
    purposes correspond to different operations. It should be impossible
    to "use the wrong store" in my cases.

  • Since drvs can end up in both the eval and build/scratch store, we
    should have some sort of union/layered store (not on the file sytem
    level, just conceptual level) that allows accessing both. This would
    get rid of the ugly "check both" boilerplate in this PR.

Still, it might be better to land this now / soon after minimal cleanup,
so we have a concrete idea of what problem better abstractions are
supposed to solve.

Depends on #9588

Priorities

Add 👍 to pull requests you find important.

@github-actions github-actions bot added with-tests Issues related to testing. PRs with tests have some priority store Issues and pull requests concerning the Nix store labels Dec 11, 2023
src/libstore/build/derivation-goal.cc Show resolved Hide resolved
if (&worker.evalStore != &worker.store) {
RealisedPath::Set inputSrcs;
for (auto & i : drv->inputSrcs)
inputSrcs.insert(i);
if (worker.evalStore.isValidPath(i))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a temporary root for it in the evalStore?

Copy link
Member Author

@Ericson2314 Ericson2314 Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is rooted by the derivation in evalStore (if that is rooted), if the derivation is in store then this whole thing is a no-op

@@ -604,7 +617,13 @@ void DerivationGoal::inputsRealised()
return *outPath;
}
else {
auto outMap = worker.evalStore.queryDerivationOutputMap(depDrvPath);
auto outMap = [&]{
for (auto * drvStore : { &worker.evalStore, &worker.store })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: {,} is a hidden overlay store

@tomberek tomberek added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label Dec 11, 2023
Copy link

dpulls bot commented Dec 11, 2023

🎉 All dependencies have been resolved !

I don't love the way this code looks. There are two larger problems:

- eval, build/scratch, destination stores (NixOS#5025) should have different
  types to reflect the fact that they are used for different purposes
  and those purposes correspond to different operations. It should be
  impossible to "use the wrong store" in my cases.

- Since drvs can end up in both the eval and build/scratch store, we
  should have some sort of union/layered store (not on the file sytem
  level, just conceptual level) that allows accessing both. This would
  get rid of the ugly "check both" boilerplate in this PR.

Still, it might be better to land this now / soon after minimal cleanup,
so we have a concrete idea of what problem better abstractions are
supposed to solve.
@Ericson2314 Ericson2314 force-pushed the floating-content-addressing-derivations-eval-store branch from 36f366b to 9f39dda Compare December 11, 2023 17:17
@Ericson2314 Ericson2314 assigned roberth and unassigned thufschmitt Dec 11, 2023
Copy link
Member

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all very scary, but at the same time it seems to be the most reasonable thing to do.
So 👍

@thufschmitt thufschmitt merged commit dfc0cee into NixOS:master Dec 12, 2023
8 checks passed
@Ericson2314 Ericson2314 deleted the floating-content-addressing-derivations-eval-store branch December 12, 2023 14:35
@Ericson2314
Copy link
Member Author

Well put! :)

@shlevy
Copy link
Member

shlevy commented Dec 22, 2023

@Ericson2314 I'm trying to get IFD to use buildStore instead of store for the builds, does this patch mean I can skip copying drvs to the buildStore?

@Ericson2314
Copy link
Member Author

@shlevy I don't think there is anything called a buildStore yet? (though perhaps there should be). So I am not quite sure how to answer your question.

drv files do end up in store for CA derivations, because resolving, but for non-CA derivations they only go in evalStore.

@shlevy
Copy link
Member

shlevy commented Dec 24, 2023

@Ericson2314 EvalState does in fact have a buildStore, though in current HEAD it's never used. However, see #9661 for what I mean. In any case, it turns out I do not need to copy anything to buildStore.

@Ericson2314
Copy link
Member Author

Oh hah! I never noticed that.

tebowy pushed a commit to tebowy/nix that referenced this pull request Jul 11, 2024
…ddressing-derivations-eval-store

Fix building CA derivations with and eval store

(cherry picked from commit dfc0cee)
Change-Id: I28feb5a36d4fe75f0ed3e3e2db6eb56b67d0f371
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. store Issues and pull requests concerning the Nix store with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants