nix-collect-garbage
nix-collect-garbage is a command-line tool used in the Nix package manager to reclaim disk space by removing unused and old built packages and dependencies. It is a garbage collection utility specifically designed for the Nix package management system. When packages are built or modified in Nix, old versions and unused dependencies can accumulate and take up disk space. nix-collect-garbage scans the Nix store directory and identifies all the items that are no longer accessible or referenced. The tool then removes these unreferenced items, freeing up disk space. It is particularly useful in scenarios where multiple versions of packages are built and installed, leading to a large number of unused artifacts. The garbage collection process performed by nix-collect-garbage is automated and efficient. By executing nix-collect-garbage, system administrators can keep the Nix store compact and prevent unnecessary disk space usage. It helps maintain the integrity of the Nix package repository by removing redundant packages and dependencies. Overall, nix-collect-garbage is a valuable tool for managing disk space and optimizing the Nix package management system.
List of commands for nix-collect-garbage:
-
nix-classic:tldr:045c4 nix-classic: Remove unused paths from Nix store.$ nix-collect-garbagetry on your machineexplain this command
-
nix-collect-garbage:tldr:0bfbe nix-collect-garbage: Simulate the deletion of old store paths.$ sudo nix-collect-garbage --delete-old --dry-runtry on your machineexplain this command
-
nix-collect-garbage:tldr:16173 nix-collect-garbage: Delete all store paths older than 30 days.$ sudo nix-collect-garbage --delete-older-than 30dtry on your machineexplain this command
-
nix-collect-garbage:tldr:179e2 nix-collect-garbage: Delete all store paths unused by current generations of each profile.$ sudo nix-collect-garbage --delete-oldtry on your machineexplain this command