Hm, I don’t see how it would. For reference, root != sudo (as you’ve noticed).
At risk of completely overloading you with detail that you don’t care about, but to clarify, sudo uses this little piece of Linux permissions called “setuid”, which allows you to make a binary owned by a certain user always execute as if the user executing it was the user that owns it. In the case of sudo, it’s owned by root, and therefore sudo itself will be executed by anyone as if they were the root user.
Sudo then asks the user for their user password, to ensure that the user is actually the one running it (and to give them a chance to check for typos), and then executes whatever you want it to as root.
The emergency mode on the other hand is executed very early at boot time, even before the kernel has fully started sometimes. It’s just a shell you’re put in, provided by systemd, which in turn is the first process that runs and always executed as root. The rescue mode shell login will ask you for the password of specifically the root user, because it literally signs in as root.
Therefore, sudo ← password of user who is configured with sudo (sometimes called wheel) permissions, rescue mode ← root user password.
Besides the fact that sudo is owned by the root user, these things are completely unrelated, and the passwords used for each are disconnected. That said, the file that stores user passwords contains both passwords and lives in
/etc/shadow. So if you broke your partitions sufficiently, that file may have disappeared, and you might not have had passwords anymore. Or maybe you accidentally got rid of the sudo config, or changed from ext4 to NTFS, or something like that. Hard to know without further debugging.
Also tangentially, when you first install NixOS it will ask you to set a password for the root user, which is the password used for that. Personally I typically disable that (with
--no-root-passwd, which just disables root login entirely), but if you do set a root password that’s the one to sign into your rescue mode.