Automatic garbage collection with package manager only

When running nixos, garbage collection can be automated by setting “nix.gc” attributes in “configuration.nix” and nix store optimisation can be automated using “nix.optimise.automatic = true;”.

For a package manager only installation on Linux, there also exists “auto-optimise-store” in nix.conf. But there appears to be no setting for automatic garbage collection. What is the recommended way to setup automatic garbage collection for a package manager only installation?

Ref:
https://nixos.wiki/wiki/Storage_optimization
https://nixos.org/manual/nix/stable/command-ref/conf-file#conf-auto-optimise-store

nix.gc basically sets up a systemd service to run nix-collect-garbage every so often, so you could just set up such a service and timer on any other system, too.

2 Likes

Thanks for your reply. I just wanted to make sure I wasn’t missing some built-in way to do it.