Proper way to delete the latest system configuration and Grub entry, not the old ones?

I recently broke my NixOS system (system-4), and rolled back to the previous working version (system-3) using:

/run/current-system/bin/switch-to-configuration boot

That correctly set my Grub default to system-3, but it didn’t delete system-4 from the Grub “All Configurations” menu.

I’d like to completely delete system-4, both from /nix/var/nix/profiles/system and from the Grub “All Configurations” menu. I don’t want to bother debugging it, just want to start over again with system-3 as the current generation system.

The manual only tells how to delete old generations. But what’s the proper way to delete the current system?

The manual only tells how to delete old generations. But what’s the proper way to delete the current system?

You can delete the various symlinks under /nix/var/nix/profiles and then garbage collect, but why bother? Just fix up the configuration and create a new generation.

1 Like

Thanks. I didn’t keep a backup of the known working configuration.nix, so all I have is the broken one. I’m not sure what broke it, so I’m not sure how easy it will be to recreate a new working generation.

I’ve since decided to rebuild my configuration.nix from the default working one, one bit at a time, using the system.copySystemConfiguration setting to keep backups of each build’s configuration.nix.

1 Like

general tip: just run git init in your /etc/nixos, don’t have to upload it anywhere, but is kind of helpful.

1 Like

Thanks. I didn’t keep a backup of the known working configuration.nix

But the configuration.nix isn’t stored as part of the generation, so even if you were to remove the non-working one, that still wouldn’t get you back to a working state. I cannot strongly enough recommend keeping the configuration in $VCS, use frequent, small commits and tag working configurations.

1 Like

with git in /etc/nixos
you are working on it with root rights …

I prefer a git repo anywhere and Symbolic Links to /etc/nixos

1 Like

Ah Yeah, I just changed the permissions of /etc/nixos so it is owned by my user; forgot that Part. But now I also use a symlink, just wanted to with the easiest solution.