No root password at install and user

Hi,

I want to install nixos without a root password. Obviously, I should use nixos-install --no-root-passwd.

But could it be a problem for creating a user after, as it is explained is the documentation ?

You should log in and change the root password with passwd.

$ useradd -c 'Eelco Dolstra' -m eelco
$ passwd eelco

So : how to create a user account without root ?

There’s an example user account in the generated configuration.nix, just uncomment it and change username to yours. After installation run this: nixos-enter --root /mnt -c 'passwd myusername'.
Do not use useradd to add users.

1 Like

Thanks for your answer.

So, if I follow correctly, for the installation procedure :

  • uncomment user account in configuration.nix and create the one associated to myusername
  • do nixos-install --no-root-passwd
  • do nixos-enter --root /mnt -c 'passwd myusername'
  • reboot
  • login with myusername and passwd

Is that right ?

If it is not the proper way to do it, why letting this in the manual/documentation ? :thinking:

passwd is the command to change passwords

No one cares enough to fix it Slightly confusing user management in the NixOS installation guide · Issue #97422 · NixOS/nixpkgs · GitHub

Between quotes ? : nixos-enter --root /mnt -c 'passwd myusername'

nixos-enter --root /mnt -c passwd myusername instead ?

nixos-enter --root /mnt -c 'passwd myusername' is correct, replace myusername with your username in configuration.nix