User declared using "users.user.?" unable to login


#1

I’ve got a user defined using users.users.name, with a custom home directory, and a custom login shell set. When I cat /etc/passwd, I see that the user’s home directory is set to /var/empty and the shell is set to /run/current-system/sw/bin/nologin. This is happening on nixos-unstable.


#2

Can you show us the relevant part of your config? You can obviously replace password hashes and similar sensitive data.


#3
  users.users."swflint" = {
    isNormalUser = true;
    uid = 1000;
    home = "/home/swflint";
    description = "Samuel W. Flint";
    shell = pkgs.zsh;
    extraGroups = [ "wheel" "networkmanager" "libvirtd" "scanner" "fuse"  ];
  };

No password or password hash is used in the config file.


#4

That looks a lot like my configuration for my user with just two differences: I didn’t specify the home directory, as /home/$USER is the default anyway and I didn’t specify a shell.
Well, and I use 18.09.

I assume that something is going wrong during your user activation at boot/switch.
Could you run the following command please? It should give you the command that is being run at system activation and should look something like this:

$ fgrep --before=3 update-users-groups.pl /run/current-system/activate
/nix/store/jpdrxba87xm2kkxf7skdh8imszv5zc5n-perl-5.28.1/bin/perl -w \
  -I/nix/store/mwqd4p1b911cfr0ggh9pcbvm1r1dgcyq-perl5.28.1-File-Slurp-9999.19/lib/perl5/site_perl \
  -I/nix/store/g70kgxcl6ifrlysnha7bfvd6w5yc4mzd-perl5.28.1-JSON-2.97001/lib/perl5/site_perl \
  /nix/store/1hkp2n6hz3ybf2rvkjkwrzgbjkrrakzl-update-users-groups.pl /nix/store/p61aj4cw8rxwxndl39px6w08a2p7n9w2-users-groups.json

Then just copy&paste the 4 lines that make up the perl command and execute it as root, so you can see what exactly is going wrong.
Here’s an example where /home is read-only:

[root@nixos:~]# /nix/store/jpdrxba87xm2kkxf7skdh8imszv5zc5n-perl-5.28.1/bin/perl -w \
>   -I/nix/store/mwqd4p1b911cfr0ggh9pcbvm1r1dgcyq-perl5.28.1-File-Slurp-9999.19/lib/perl5/site_perl \
>   -I/nix/store/g70kgxcl6ifrlysnha7bfvd6w5yc4mzd-perl5.28.1-JSON-2.97001/lib/perl5/site_perl \
>   /nix/store/1hkp2n6hz3ybf2rvkjkwrzgbjkrrakzl-update-users-groups.pl /nix/store/6zwa0n1abmd3wkwq0pbcxsc20c8r9c25-users-groups.json
mkdir /home/swflint: Permission denied at /nix/store/1hkp2n6hz3ybf2rvkjkwrzgbjkrrakzl-update-users-groups.pl line 216.

#5

This generates no errors, however, the JSON file leaves description as an empty string, createHome as false, group as nogroup, home as /var/empty and uid as null, and likewise for any other ‘users-groups.json’ found.


#6

Sorry for wasting time – turns out, the “users.nix” file that contains the definition was not included in “configuration.nix”. How I managed not to, I’m not sure.


#7

I know that feeling a bit too well from my own experience :slight_smile:
Good to know that you found and fixed the issue.