Difference between revisions of "Cleaning the nix store"
From NixOS Wiki
m (Fixed syntax highlighting) |
(Add warning about the new wiki) |
||
Line 1: | Line 1: | ||
+ | {{warning|1=You are reading an article on the deprecated unofficial wiki. For the up to date version of this article, see https://wiki.nixos.org/wiki/Cleaning_the_nix_store.}} | ||
+ | |||
Sometimes your store fills up the disk, but a simple | Sometimes your store fills up the disk, but a simple | ||
<syntaxhighlight lang=text>nix-store --gc</syntaxhighlight> | <syntaxhighlight lang=text>nix-store --gc</syntaxhighlight> |
Revision as of 16:27, 4 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:
- https://matthewrhone.dev/nixos-package-guide#cleanup-old-packages-user-wide
- https://nixos.wiki/wiki/Storage_optimization
- https://old.reddit.com/r/NixOS/comments/8m1n3d/taking_out_the_trash/
There are multiple tools that can help with discovering gcroots and calculate the disk size: