rustshop / npcnix

Control your NixOS instances system configuration from a centrally managed location
49 stars 1 forks source link

sudo nixos-rebuild switch resets the machine #3

Open douglaz opened 11 months ago

douglaz commented 11 months ago

If we run sudo nixos-rebuild switch it will uninstall everything and remove all the user access, making the machine unavailable. We should have some kind of protection against this

dpc commented 11 months ago

By default sudo nixos-rebuild switch will set the machine to use /etc/nixos/configuration.nix configuration.

Normally npcnix will do something like sudo nixos-rebuild switch --flake . in a directory that contains a flake with the desired configuration.

If you were to run sudo nixos-rebuild switch --flake . with the desired config again, everything would switch back to how it should be.

But yeah, I have not thought anyone would be running these manually. :D

dpc commented 11 months ago

I think if we delete /etc/nixos/configuration.nix, sudo nixos-rebuild switch will just fail.

dpc commented 11 months ago

Oh. And I think setting install = true in the terraform again would restore the machine as well.