Forrest logo
back to the nix-collect-garbage tool

nix-collect-garbage:tldr:179e2

nix-collect-garbage: Delete all store paths unused by current generations of each profile.
$ sudo nix-collect-garbage --delete-old
try on your machine

The command sudo nix-collect-garbage --delete-old is used to clean up the Nix store in a Nix package manager. Here's how it works:

  • sudo: It is a command used to run the following command with administrative privileges. It is often required for system-wide maintenance tasks.
  • nix-collect-garbage: This is the main command used to clean up the Nix store. When executed, it removes unused or outdated packages and their dependencies from the store.
  • --delete-old: It is an option passed to the nix-collect-garbage command that directs it to delete old generations of packages. Generations represent previous versions of packages, and by running this command with --delete-old, all generations except the latest one are removed.

By running this command with administrative privileges, it cleans up the Nix store by deleting unused packages and removing old generations, thereby reclaiming disk space and ensuring a more efficient use of the Nix package manager.

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-collect-garbage tool