If you need to get a root shell on a NixOS[1] 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.)
Ref. https://github.com/systemd/systemd/commit/33eb44fe4a8d7971b5614bc4c2d90f8d91cce66c
[1]: Or any GNU/Linux distro really.