Today my nixos is so broken after update and won’t boot. I partially fixed it with liveusb and able to booted into it again. I garbage collect all the things to try fixing the config as I think there were something broken in nix store. Then I run nixos-rebuild switch. But then it hang again, I have to long press power button to turn off the computer. Now it cannot recognize my SSD and boot strict to BIOS again, so I have to use live-usb, mount all the filesystem and then run nixos-enter to enter the environment again.
When running as root in nixos-enter, I run this command in my flake repo: nixos-rebuild switch --flake .#my_host
This is the output:
building the system configuration...
Checking switch inhibitors... done
update GRUB 2 menu...
Error: Failed to open dbus connection
Caused by:
Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Command '/nix/store/................./bin/switch-to-configuration switch' returned non-zero exit status 1.
Then I tried to switch to my own user with su - user and run sudo nixos-rebuild switch --flake .#my_host
sudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set
After both the SSD is still not bootable. I do not know what to do now.