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

How do I create static caches using nix 2.0 in the same way nix-push did? #2123

Open
ryantrinkle opened this issue Apr 29, 2018 · 7 comments
Labels
feature Feature request or proposal stale

Comments

@ryantrinkle
Copy link

Previously, I used a command like:

nix-push --dest "$TMPDIR" --key-file ~/.reflex-platform/ryantrinkle.com-1 "$derivation"

to push a derivation and its dependencies to a temp directory, which I then synced to AWS S3.

While the docs say "The command nix-push has been removed as part of the effort to eliminate Nix's dependency on Perl. You can use nix copy instead, e.g. nix copy --to file:///tmp/my-binary-cache paths…", I haven't been able to determine how to do this (after asking on #nixos).

How can I reproduce the original functionality of nix-push? In particular, the things that seem different are:

  • It produced nars and narinfos, not a new nix store
  • It signed things on the fly, rather than using signatures in the store
@lheckemann
Copy link
Member

lheckemann commented May 2, 2018

nix sign-paths -k ~/.reflex-platform/ryantrinkle.com-1 "$derivation"
nix copy --to "file://$TMPDIR" "$derivation"

Note the file: scheme in the URL, which differentiates between a flat-file binary cache and a chroot store.

EDIT: This doesn't answer the "sign on the fly" part of the question. Do you actually have a reason not to keep the signatures in the store?

@edolstra
Copy link
Member

edolstra commented May 7, 2018

It would probably be nice if nix copy had a flag to add new signatures.

@edolstra edolstra added the feature Feature request or proposal label May 7, 2018
@ElvishJerricco
Copy link
Contributor

ElvishJerricco commented May 8, 2018

You can do the signing in the file:// afterwards.

$ nix copy --to "file://$TMPDIR" "$derivation"
$ nix sign-paths --store "file://$TMPDIR" -k ~/.reflex-platform/ryantrinkle.com-1 "$derivation" -r

Note that I added -r, which will make sure to sign recursively.

EDIT: Fixed code

@bjornfor
Copy link
Contributor

Adding this here for discoverability. (This confused me a lot.) The "file://" part of "nix copy --to file:// ..." is very important. Without it you get this

nix-build foo.nix
nix copy --to /tmp/test-binary-cache ./result
error: cannot add path '/nix/store/m21r56hnxs905qp82ymcgwc582qrqrj3-foo' because it lacks a valid signature

(Signing the path doesn't help.)

@bjornfor
Copy link
Contributor

Latest Nix (still) does not run in constant memory for file:// binary caches, ref #2774. This forces me to use nix-1.x to create binary caches at work.

@stale
Copy link

stale bot commented Feb 20, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 20, 2021
@stale
Copy link

stale bot commented Apr 28, 2022

I closed this issue due to inactivity. → More info

@stale stale bot closed this as completed Apr 28, 2022
@thufschmitt thufschmitt reopened this Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal stale
Projects
None yet
Development

No branches or pull requests

6 participants