-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
A command to add a gc root #7138
Comments
@roberth i believe the command is |
That only works for derivations after |
@roberth The # Check existing symlink (not a GC root yet)
$ ls -lA | grep pre-commit
lrwxr-xr-x 1 chrisw staff 66 Nov 9 22:33 .pre-commit-config.yaml -> /nix/store/q9gq4gasykzawdgamgsq06gsw9pyr56c-pre-commit-config.json
# Check whether we can add a GC root using nix-store
$ nix-store --add-root PRECOMMIT-TEST-ROOT -r $(readlink -f .pre-commit-config.yaml)
/Users/chrisw/TEST/PRECOMMIT-TEST-ROOT
# Check it points at the right thing
$ ls -lA | grep pre-commit
lrwxr-xr-x 1 chrisw staff 66 Nov 9 22:33 .pre-commit-config.yaml -> /nix/store/q9gq4gasykzawdgamgsq06gsw9pyr56c-pre-commit-config.json
lrwxr-xr-x 1 chrisw staff 66 Nov 10 12:16 PRECOMMIT-TEST-ROOT -> /nix/store/q9gq4gasykzawdgamgsq06gsw9pyr56c-pre-commit-config.json
# Check the GC root was created
$ ls -lA /nix/var/nix/gcroots/auto/ | grep PRECOMMIT
lrwxr-xr-x 1 root nixbld 51 Nov 10 12:16 g8wvba0kpaysc69vhlhs0jn1ymv1qwg8 -> /Users/chrisw/TEST/PRECOMMIT-TEST-ROOT |
That could indeed be useful as a plumbing command for the new CLI. In the meantime, |
Thanks! |
I think this is still necessary. I believe there should be a way to create a GC root for a derivation without realising that derivation. The motivation for this is so that it can be used in conjunction with |
#7261 would make it easier to do things to |
I would really like something like this for a remote store. We launch our builds from docker containers that use the host's socket to do building but need a way to generate roots on the host. |
Instead of using cachix, I use one of my machine for cache. Build the whole systems on GitHub action and upload it. Using Anyway, an official feature is definitely expected. |
I can use this command to create a gc root (I think):
|
I found a way 🪄 !
This is obviously not a very good solution, but if it can help anyone in the meantime... It sure helped me :-) |
Is your feature request related to a problem? Please describe.
I'm generating a script that needs create an indirect gc root to a store path that's in the script's closure. E.g.
Describe the solution you'd like
A new command as follows. (I didn't find a suitable command in the unstable manual or the nix-store manpage)
Here's a fictional doc I hope we can turn into reality.
Create an indirect garbage collection root at location
path
to refer to thestorepath
.Note that most commands that produce store paths have an option to produce a garbage collection root, so that the store path can not be garbage collected before a root is created.
A valid use case for
nix store add-root
is in scripts built with Nix. In this case the store path is already referenced by the script's store path, andnix store add-root
is used to prevent collection of the store path after the script exits.Describe alternatives you've considered
Abusing some other command to create the root and then replace the symlink. This is bad because it's complicated and may leave the symlink in a bad state.
Additional context
The text was updated successfully, but these errors were encountered: