Difference between revisions of "Cleaning the nix store"

From NixOS Wiki
Jump to: navigation, search
m (some cleanup)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
Sometimes your store fills up the disk, but a simple
 
Sometimes your store fills up the disk, but a simple
<syntaxhighlight>nix-store --gc</syntaxhighlight>
+
<syntaxhighlight lang=text>nix-store --gc</syntaxhighlight>
 
does not seem to clean all that much.
 
does not seem to clean all that much.
  
Line 7: Line 7:
 
Sometimes <code>result</code> files created by an ad-hoc <code>nix-build</code> bind a lot of resources, these can be found by running:
 
Sometimes <code>result</code> files created by an ad-hoc <code>nix-build</code> bind a lot of resources, these can be found by running:
  
<syntaxhighlight>
+
<syntaxhighlight lang=shell>
 
   nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/\w+-system|\{memory|/proc)"
 
   nix-store --gc --print-roots | egrep -v "^(/nix/var|/run/\w+-system|\{memory|/proc)"
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 11:02, 6 April 2024

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:

There are multiple tools that can help with discovering gcroots and calculate the disk size: