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

Add builtins.fetchClosure #6302

Merged
merged 12 commits into from
Mar 24, 2022
Merged

Add builtins.fetchClosure #6302

merged 12 commits into from
Mar 24, 2022

Conversation

edolstra
Copy link
Member

This function allows fetching a previously built closure from a binary cache at evaluation time. For instance:

builtins.fetchClosure {
  fromStore = "https://cache.nixos.org";
  fromPath = /nix/store/r2jd6ygnmirm2g803mksqqjm4y39yi6i-git-2.33.1;
  toPath = /nix/store/ldbhlwhh39wha58rm61bkiiwm6j7211j-git-2.33.1;
}

fetches /nix/store/r2jd... from the specified binary cache, and rewrites it into the content-addressed store path /nix/store/ldbh.... This is similar to builtins.storePath in that it allows you to use a previously built store path in a Nix expression. However, it is more reproducible because it requires specifying a binary cache from which the path can be fetched (so it's a better alternative to #5868). Also, requiring a content-addressed final store path avoids the need for users to configure binary cache public keys.

This PR also renames nix store make-content-addressable to nix store make-content-addressed, fixes #6300, and allows it to rewrite a closure from another store in one operation.

This allows closures to be imported at evaluation time, without
requiring the user to configure substituters. E.g.

  builtins.fetchClosure {
    storePath = /nix/store/f89g6yi63m1ywfxj96whv5sxsm74w5ka-python3.9-sqlparse-0.4.2;
    from = "https://cache.ngi0.nixos.org";
  }
The advantage is that the resulting closure doesn't need to be signed,
so you don't need to configure any binary cache keys on the client.
LocalStore::addToStore() since
79ae9e4 expects a regular NAR hash,
rather than a NAR hash modulo self-references. Fixes NixOS#6300.

Also, makeContentAddressed() now rewrites the entire closure (so 'nix
store make-content-addressable' no longer needs '-r'). See NixOS#6301.
@edolstra edolstra merged commit d9cfd85 into NixOS:master Mar 24, 2022
@edolstra edolstra deleted the fetch-closure branch March 24, 2022 21:14
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tweag-nix-dev-update-27/18433/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'nix store make-content-addressable' broken on some paths
3 participants