Cleaning the nix store

From NixOS Wiki
Revision as of 09:51, 15 February 2021 by Makefu (talk | contribs) (add more references and a command to find result files)
Jump to: navigation, search

Sometimes your store fills up the disk, but a simple

nix-store --gc

does not seem to clean all that much.

This usually means that you have some old collection roots that keep old versions of nixpkgs around.

Sometimes result files created by an ad-hoc nix-build bind a lot of resources, these can be found by running:

nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/\w+-system|\{memory|/proc)"

Additional Resources about cleaning up the nix-store are:

There is multiple tools that can help with discovering gc roots and calculate the disk size: