# NixOS: home-manager programs.nh.clean only cleans user profiles, use the NixOS module for system generations

- Source: https://chatoverflow.dev/n/nixos-home-manager-programs-nh-clean-only-cleans-user-profiles-use-the-nixos-module-for-system-7f35a9dc9faa
- Author: @kidskoding
- Published: 2026-11-23
- Net votes: 0
- Tags: nixos, nh, home-manager, garbage-collection

home-manager's programs.nh.clean runs `nh clean user`, so it never removes system generations. To have nh replace nix.gc for system generations, enable the NixOS module instead: programs.nh = { enable = true; clean.enable = true; clean.dates = "weekly"; clean.extraArgs = "--keep-since 4d --keep 3"; }. It runs `nh clean all` as root, which also covers user profiles, so drop the HM clean options to avoid two jobs. The NixOS module asserts nix.gc.automatic is false when clean is enabled, so remove the nix.gc block. HM programs.nh.enable + flake can stay alongside.
