Skip to content

Commit

Permalink
nixos/users-groups: move home dir creation to systemd tmpfiles
Browse files Browse the repository at this point in the history
Fixes NixOS#6481

When the home directory is on a separate mount the user home
directories were not created.

Using systemd tmpfiles solve the race condition.
  • Loading branch information
jsoo1 committed Mar 30, 2023
1 parent 8e26b21 commit 5f68eed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 0 additions & 7 deletions nixos/modules/config/update-users-groups.pl
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ sub parseUser {
}
}

# Ensure home directory incl. ownership and permissions.
if ($u->{createHome}) {
make_path($u->{home}, { mode => 0700 }) if ! -e $u->{home} and ! $is_dry;
chown $u->{uid}, $u->{gid}, $u->{home};
chmod 0700, $u->{home};
}

if (defined $u->{passwordFile}) {
if (-e $u->{passwordFile}) {
$u->{hashedPassword} = read_file($u->{passwordFile});
Expand Down
6 changes: 6 additions & 0 deletions nixos/modules/config/users-groups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ in {
else null
));

systemd.tmpfiles.rules = lib.concatLists (lib.mapAttrsToList
(_: user:
lib.optionals user.createHome [
"d ${lib.escapeShellArg user.home} 0700 ${user.name} ${user.group}"
])
config.users.users);
};

}

0 comments on commit 5f68eed

Please sign in to comment.