Forrest logo
back to the nix tool

nix:tldr:90303

nix: Remove unused paths from Nix store to free up space.
$ nix store gc
try on your machine

The command "nix store gc" is used to perform garbage collection in the Nix store. Nix is a purely functional package manager, and the Nix store is where it keeps all installed packages and their dependencies.

Garbage collection in this context means removing any packages and their dependencies that are no longer referenced by any other package or the system. This helps to free up disk space by removing unused dependencies and old versions of packages.

When you run "nix store gc", it will scan the Nix store and identify packages that can be safely deleted. It will then remove them from the store, freeing up disk space. It will also update the store’s metadata to reflect the changes.

It's worth noting that you typically don't need to run "nix store gc" manually, as Nix automatically performs garbage collection in the background. However, you may choose to run it manually if you want to immediately free up disk space or want to ensure that the Nix store is cleaned up.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nix tool