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-based lock-based fetching #355909

Open
roberth opened this issue Nov 14, 2024 · 0 comments
Open

Dynamic derivations-based lock-based fetching #355909

roberth opened this issue Nov 14, 2024 · 0 comments

Comments

@roberth
Copy link
Member

roberth commented Nov 14, 2024

Project description

Consider that

It would be great to be able to fetch a lock file from anywhere instead, using a fixed-output derivation.
However, in many cases, we'd then use the Nix expression language to analyze, which is not something we're allowed to do in Nixpkgs, because it creates an undesirable data dependency on builds, known as import-from-derivation (IFD)

RFC 92 proposes a generalization of derivations that is weaker than IFD, avoiding the undesirable data dependency, ensuring that the evaluator can exit before builds commence, among other things.
Specifically what it does allow is for a derivation to compute another derivation as its output, and for expressions to reference outputs of outputs (where the latter is a computed derivation).

This new capability allows for a new fetching strategy to be used.

flowchart LR
    make-fetched-dependencies -- references --> fetched-lockfile
    fetched-dependencies --references --> fetched-lockfile["lock file (FOD)"]
    make-fetched-dependencies -- has output --> fetched-dependencies
    subgraph dynamic
      fetched-dependencies --references --> fetched-dependency-1["fetched dependency 1 (FOD)"]
      fetched-dependencies --references --> fetched-dependency-n["fetched dependency n (FOD)"]
    end
    the-actual-build --references --> fetched-dependencies
    the-actual-build --calls builtins.outputOf on --> make-fetched-dependencies
    fetched-dependency-1 -.....- fetched-dependency-n
Loading

Caveats and limitations

  • This is a long-term project. Initially solutions like this will be proofs of concept, which inform the development and prioritization, and are a stepping stone towards production use in Nixpkgs.
  • RFC 92 is unreleased due to a bug it had in the scheduler
    • this bug results in a store path not being scheduled sometimes, and is otherwise harmless
    • workaround: invoke Nix again
    • you can run Revert "Revert "Adapt scheduler to work with dynamic derivations nix#9415
      • use something --store ~/rfc92-store to avoid your "production" daemon which doesn't have dynamic derivation support yet
      • nix run nix/dynamic-derivations -- --store ~/rfc92-store build <argument>
  • This strategy is currently most suited for use with language package managers that fetch pre-built dependencies, such as the JavaScript and JVM ecosystems. Go is probably also ok, because it's acceptable to build dependencies in the main derivation anyway.
  • The dynamic part is, as you can see in the diagram, a graph. In order to create the dependencies (fetched-dependency 1..n), you'll need to enable recursive-nix.
    • Instead of recursive-nix's almost complete nix-daemon, we'd like to provide a simple protocol with only "store add" functionality, such as creating derivations and "normal" content-addressed store paths, but no "build" or "realise" commands. This is not implemented, so use recursive-nix instead, limiting yourself to only adding derivations.

Context

Get in touch with @Ericson2314 @tomberek @roberth, who are also in the nix-dev matrix room


Add a 👍 reaction to issues you find important.

@roberth roberth added 0.kind: enhancement Add something new 0.kind: packaging request Request for a new package to be added labels Nov 14, 2024
@tomodachi94 tomodachi94 added 6.topic: developer experience and removed 0.kind: packaging request Request for a new package to be added labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants