Kitaab

Nix Garbage Collection

nix ops

published 2022-07-21 20:43

updated 2022-12-07 16:48

This will delete all generations asides from the currently installed one nix-env --delete-generations old

You could also do by date instead nix-env --delete-generations 7d

Now that the generations are gone you can clean up some space from the nix store too: nix-store --gc

In dire circumstances one can do: sudo rm -r/run/booted-system/ sudo nix-garbage-collect -d

Sometimes result from random nix-builds will add up storage. Find them with: nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/\w+-system|\{memory|/proc)"