How to use users.users.<name>.passwordFile?

I’m having trouble using the passwordFile option. I have a test user named “asdf” with password “pass”. Using mkpasswd -m sha-512 pass I get something like $6$lJe..., whatever let’s call it <hashed>. Now when I do

users.users.asdf.hashedPassword = "<hashed>";

everything works fine, but when I try to use passwordFile, eg.

# /etc/passwordFile

# /etc/nixos/configuration.nix
users.users.asdf.passwordFile = "/etc/passwordFile";

I can’t login. I just get a “Login incorrect” error.

Oddly enough I’m also no longer to login as root even though root's password was set by nixos-install and I don’t have any users.users.root configuration in /etc/nixos/configuration.nix.

Does anyone have any ideas what could be going on here?

Have you tried without asdf:?


Have you tried without asdf:?

This is probably the answer, according to the docs:

The file should contain exactly one line, which should be the password in an encrypted form that is suitable for the chpasswd -e command.

1 Like

Thanks! Trying without asdf: worked.

The docs threw me off since man chpasswd says:

Each line is of the format:


Perhaps we could add an example to the docs?