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

Option to add root for copy commands. #4002

Open
kevincox opened this issue Sep 9, 2020 · 9 comments
Open

Option to add root for copy commands. #4002

kevincox opened this issue Sep 9, 2020 · 9 comments

Comments

@kevincox
Copy link
Contributor

kevincox commented Sep 9, 2020

Is your feature request related to a problem? Please describe.

Right now if you copy a derivation to another machine such as nix-copy-closure machine.example ./result it is liable to be garbage collected as soon as it is copied.

Describe the solution you'd like

A way to copy a closure to a remote machine and atomically root it. Both system roots and indirect roots would be useful.

@aycanirican
Copy link
Member

To tackle this problem we first copy the closure and then install it to the environment:

nix copy --from https://$BINARY_CACHE/nix $DRV
# optionally: nix-env -e package_name
nix-env -i $DRV

@kevincox
Copy link
Contributor Author

kevincox commented Sep 9, 2020

This is similar to what I am doing right now, just using nix-store -r --add-root after the copy. However neither of these options are convenient or atomic. If you get unlucky the garbage collector will run between your two commands and delete the packages you just copied.

@kloenk
Copy link
Member

kloenk commented Sep 11, 2020

So you would propose something like:

nix copy --to ssh-ng://target?gc-root=/home/$USER/result ./result

@kevincox
Copy link
Contributor Author

I think the following would work and be slightly more obvious:

nix copy --to ssh-ng://target --add-root=/home/$USER/result ./result

Currently nix-store -r --add-root requires a separate argument for indirect, however I think that can be simplified if the root is outside of /nix/var/nix/gcroots just automatically make it indirect.

@kevincox
Copy link
Contributor Author

Your option would make more sense if you can specify multiple targets. However right now it appears that additional --to flags overwrite the former ones. (That should probably be fixed too, but that's another issue).

@stale
Copy link

stale bot commented Mar 16, 2021

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

@stale stale bot added the stale label Mar 16, 2021
@kevincox
Copy link
Contributor Author

kevincox commented Mar 16, 2021 via email

@stale stale bot removed the stale label Mar 16, 2021
@stale
Copy link

stale bot commented Sep 14, 2021

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

@edolstra
Copy link
Member

#11657 adds --profile and --out-link options to nix copy that would enable doing this for local stores. If remote stores ever get support for creating roots (#11812), then it would automatically work for remote stores as well.

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

No branches or pull requests

5 participants