I’m seriously short on space and want to free-up some SSD.
As far as I understand, packages that are dependent to a system (or derivation) wouldn’t be garbage collected, so my question is how can I delete the old derivations, so gc clean the old packages, I free up some space and make my boot menu a lot cleaner!
nix-store --gc and
nix-env --delete-generations old and retrying the prior after the latter, still I see all of them on my boot menu, are they deleted? Am I doing or assuming sth significantly wrong?
Also, How can I use regex to delete derivations? Is it even supported?
They won’t get removed from your (grub, at least) boot menu until the next
nixos-rebuild switch, because that’s what builds the menu.
Then how can I ensure it? (That those are gone)
Because it seemed like GC didn’t do anything afterward, tho I don’t know how can I ensure and I don’t have enough space for a rebuild
Sorry, I assumed the gc had cleaned the space and you were just still seeing the old boot entries.
nix-collect-garbage -d is the shorthand for expiring all old generations and then gc’ing the store. Does that make a difference? Otherwise you may just have too little space (or too much usage elsewhere as well) or we need to debug store size
I guess it did the trick
18 store paths deleted, 136.48 MiB freed
But also you are right about the 2nd part, my system is still too full due to sth, maybe it’s just I have alot of things! I tried Filelight (KDE) to visualize my disk usage and it didn’t end well, because it couldn’t see the whole system (for some not exactly obvious reason for me / just home and var). it was reporting 11.8 GBs while I’m sure my SSD is 250ish GBs and it’s full air tight (or at least it was before this cleanup) probably FS access restrictions (maybe I should try running a non-gui tool on terminal as root)
Now I even tried to delete logs (4GBs) and even
journalctl --vacuum-size=4000M is failing to cleanup anything more than 100MB
Anyways I guess continuing this thread any further would drift away from Nix and NixOS to my own specific case; So I guess for sake of community harmony I set your last message as solution and call it a day!
If I become able to rebuild with this extra 300MBs I’ll inform you boot menu is fixed or not
I usually use
sudo nix-store --gc --print-roots to learn where there are GC roots left in the system, which also are results of an unthoughtful
nix build somewhere in a place you usually do not visit.
nix-direnv accumulating its own history of shells that will never be resused again.
PS: I’m also quite on the fence of using
-delete-old for no reason, but many users suggest it as the onestop solution. Please use
--delete-older-than with an appropriate period to make sure you’ll be left with something to rollback to.
This is not nix-specific but I found out that
~/.cacheis often quite large and is worth removing from time to time (they are non-essential cache files used by programs to speed things up)
I reinstalled the system from the file, and made the vol btrfs, dunno which one helped the CoW mechanism of BTRFS or reinstall but now my system has a lot of free space, which is unexpected for me
You may also enabled compression and/or deduplication?
dedupliation is I guess the default in btrfs and about compression, I really don’t know! I don’t have a visible performance hit (I just set it as btrfs and let the nixos do the magic so everything is the defaults)
Compression does not have any visible performance hit on my system (I also heard that sometimes it’s accelerated by the hardware). Actually I think it can even be faster if your CPU compresses quicker than it takes for your disk to write the file (often disks are quite slow compared to cpu).