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

Dynamic derivations RFC 92 #4628

Merged
merged 3 commits into from
Sep 7, 2023
Merged

Commits on Sep 6, 2023

  1. Improve derivation parsing

    - Don't assert: Derivation ATerms are not necessarily produced by Nix,
      and parsers should always throw graceful errors
    
    - Improve error message from `static void except(..)`, shows both what
      we expected and what we actually got.
    
    The intention is that we backport it, and then hopefully a few people
    might get slightly better errors if they try out new experimental drv
    files (for RFC 92) with an old version of Nix.
    Ericson2314 committed Sep 6, 2023
    Configuration menu
    Copy the full SHA
    b7edc20 View commit details
    Browse the repository at this point in the history

Commits on Sep 7, 2023

  1. Allow dynamic derivation deps in inputDrvs

    We use the same nested map representation we used for goals, again in
    order to save space. We might someday want to combine with `inputDrvs`,
    by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
    not doing that yet for sake of a smaller diff.
    
    The ATerm format for Derivations also needs to be extended, in addition
    to the in-memory format. To accomodate this, we added a new basic
    versioning scheme, so old versions of Nix will get nice errors. (And
    going forward, if the ATerm format changes again the errors will be even
    better.)
    
    `parsedStrings`, an internal function used as part of parsing
    derivations in A-Term format, used to consume the final `]` but expect
    the initial `[` to already be consumed. This made for what looked like
    unbalanced brackets at callsites, which was confusing. Now it consumes
    both which is hopefully less confusing.
    
    As part of testing, we also created a unit test for the A-Term format for
    regular non-experimental derivations too.
    
    Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
    Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
    
    Apply suggestions from code review
    
    Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
    Ericson2314 and roberth committed Sep 7, 2023
    Configuration menu
    Copy the full SHA
    7ad66cb View commit details
    Browse the repository at this point in the history
  2. Special-case error message to add extra information

    The Derivation parser and old ATerm unfortunately leaves few ways to get
    nice errors when an old version of Nix encounters a new version of the
    format. The most likely scenario for this to occur is with a new client
    making a derivation that the old daemon it is communicating with cannot
    understand.
    
    The extensions we just created for dynamic derivation deps will add a
    version field, solving the problem going forward, but there is still the
    issue of what to do about old versions of Nix up to now.
    
    The solution here is to carefully catch the bad error from the daemon
    that is likely to indicate this problem, and add some extra context to
    it.
    
    There is another "Ugly backwards compatibility hack" in
    `remote-store.cc` that also works by transforming an error.
    
    Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
    Ericson2314 and roberth committed Sep 7, 2023
    Configuration menu
    Copy the full SHA
    80d7994 View commit details
    Browse the repository at this point in the history