If you need to get a root shell on a NixOS machine and the root account is disabled/locked (and/or you’ve forgotten all your passwords), here’s how to do it (without booting a live ISO).
When the machine boots, interrupt the bootloader and add this to the bootloader command-line:
[...] rescue systemd.setenv=SYSTEMD_SULOGIN_FORCE=1
(Without SYSTEMD_SULOGIN_FORCE=1 you will not be able to get a shell if the root account is disabled/locked.)
: Or any GNU/Linux distro really.