but this leaves me with many some-dir-.direnv-nix-profile links in my gcroots, even multiples for the same project dirs.
Is there an idiomatic way to only keep the last instance for each dir and GC all the rest?
Or do I have to resort to some (periodically executed) script that scans gcroots and cleans it up?
I guess in the latter case one would first delete the link target and then just delete all broken links under gcroots recursively, which would additional cleanup otherwise broken links?
(I noticed this post is somewhat related, I guess I might try to use nix-store to interact with the symlinks / query differently, but top level the issue remains the same)
nix-collect-garbage -d leaves many links under gcroots intact on my system, also broken ones. For the non-broken ones I think the issue is that the link it points to still exists, but these are still (up to) many ....direnv... generations per project.
(As a side note: I manually removed also some old channel links etc., but these were most likely leftovers from before I flakified my systems)
nix-collect-garbage -d leaves many links under gcroots intact on my system, also broken ones. For the non-broken ones I think the issue is that the link it points to still exists, but these are still (up to) many ....direnv... generations per project.
Hmm, if there are many direnv generations in a way not understood by Nix, maybe it is a direnv side issue then… Does cleaning up the profiles there suffice, at least?
Indeed I think this is direnv’s fault, and I guess nix wouldn’t be able to distinguish several direnv generations without specific code. What I basically did is manually look for all links (in gcroots) that contain .direnv and just delete them. Of course after that nix-collect-garbage cleans everything up, but for it to keep the last generation I’d have to refine the process significantly. (That would involve a script that recursively scans all gcroots and makes assumptions about name patterns).
The OP was meant to illustrate this, and to check whether I might be missing “prior art” to solve this, since I figure most direnv users must be suffering from this?