`nix-collect-garbage -d` not deleting everything that it should

I recently updated my system by:

  1. Updating the root channel with nix-channel --update

  2. Upgrading the nixos installation with nixos-rebuild --upgrade boot

  3. Rebooting in the new system

After that, I tried to purge the old system by doing nix-collect-garbage -d as root. And it did not delete the old system completely:

[$] ls /nix/store/*nixos-system-nixos* -d                                                                                                                    

There are still two derivations from the old system (19.09.976.c75de8bc12c). No other derivation refers to these derivations. Why weren’t these derivations deleted as well?

Have you checked if they are perhaps still referenced in a user’s profile?

Or from a nix build you did and didn’t delete the result link?

You can check in /nix/var/nix/{profiles,gcroots}/per-user/* if there are any links pointing to those old configurations.

Be aware that they are not necessarily referenced directly, but might be a transient dependency of what is linked from there.

1 Like