-
-
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
nix-shell dependencies can be garbage collected any time now / persistent nix-shell envs #2208
Comments
@edolstra any thoughts? suggestion on this ^ |
Method 1 makes gcroot for shell derivation, this indeed doesnt prevent it dependencies to be garbage collected I have made script that makes same as method 2
tnx to http://nix-dev.science.uu.narkive.com/QjeSH005/truly-persistent-nix-shell |
Do you have the |
@lheckemann no, I dont have this options
|
|
@lheckemann with keep-outputs and using this script
garbage collector indeed keep dependencies of shell, neat trick, but I still use the previous version of the script since |
It appears that the derivations produced by nix-direnv are removed when running nix's garbage collection. Troubleshooting this issue led me to a git issue in the NixOS/nix repo [1]. Enabling both `keep-derivations` and `keep-outputs` worked for me as recommended, and now nix-direnv is working. [1]: NixOS/nix#2208
While the script above works, I'd really love to have a first-class feature like this. Protecting a shell's dependencies from garbage collection is something I'd expect to be immediately configurable, I mean, per shell. Is it possible for nix-shell to check some "protected" setting in shell.nix and accordingly update relevant gc roots? Said roots should probably also be removed when the setting is switched off. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/pinned-nixpkgs-keeps-getting-garbage-collected/12912/5 |
Found a solution:
This will build a dummy derivation that has the shell's inputs as runtime dependencies, and place a GC root into |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/starting-nix-shell-without-rebuilding/16394/7 |
Isn't |
I was surprised that |
Gentle bumb @edolstra , since this seems like essential functionality. I suspect a lot of people would like to not download the entire internet every time an often used nix-shell gets garbage collected. Can we have an easy to use option to keep a nix-shell and its dependencies? See kevincox's post directly above. |
@sleirsgoevy will the old derivation be included in the GC when I change the |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-09-nix-team-meeting-minutes-15/23951/1 |
Discussed in Nix team meeting on 2022-12-19. Decision: closing as won't fix. Complete discussion
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-16-nix-team-meeting-minutes-17/24120/1 |
What's the nix develop way to solve this? I tried to use |
There does not seem to be a way to prevent nix-shell dependencies from being garbage collected at any time. Related to this, for a while now there been possible to create persistent nix-shell environments that would be spared garbage collection. Neither of the two methods (see below) are now working.
shell.nix
Previous Method 1 (https://nixos.org/nix-dev/2016-November/022173.html):
While this does create a gcroot to the derivatation, it does not work (my guess cause it is not a gcroot to the build output)
If nix-collect-gc is run while the shell is active it cleans up everything this derivation depends on
Previous Method 2:
This used to create symlinks to dependencies, how ever since
--indirect
is now ignored as of 19477e8 this also no longer works as gcroot to the output is no longer created.Please advise on this
The text was updated successfully, but these errors were encountered: