···223 }
224225 # Ensure home directory incl. ownership and permissions.
226- if ($u->{createHome}) {
227- make_path($u->{home}, { mode => 0700 }) if ! -e $u->{home} and ! $is_dry;
228 chown $u->{uid}, $u->{gid}, $u->{home};
229- chmod 0700, $u->{home};
230 }
231232 if (defined $u->{passwordFile}) {
···223 }
224225 # Ensure home directory incl. ownership and permissions.
226+ if ($u->{createHome} and !$is_dry) {
227+ make_path($u->{home}, { mode => oct($u->{homeMode}) }) if ! -e $u->{home};
228 chown $u->{uid}, $u->{gid}, $u->{home};
229+ chmod oct($u->{homeMode}), $u->{home};
230 }
231232 if (defined $u->{passwordFile}) {
+9-2
nixos/modules/config/users-groups.nix
···48 services such as SSH, or indirectly via <command>su</command> or
49 <command>sudo</command>). This should only be used for e.g. bootable
50 live systems. Note: this is different from setting an empty password,
51- which ca be achieved using <option>users.users.<name?>.password</option>.
5253 If set to <literal>null</literal> (default) this user will not
54 be able to log in using a password (i.e. via <command>login</command>
···139 description = "The user's home directory.";
140 };
141000000142 cryptHomeLuks = mkOption {
143 type = with types; nullOr str;
144 default = null;
···319 group = mkDefault "users";
320 createHome = mkDefault true;
321 home = mkDefault "/home/${config.name}";
0322 useDefaultShell = mkDefault true;
323 isSystemUser = mkDefault false;
324 })
···430 inherit (cfg) mutableUsers;
431 users = mapAttrsToList (_: u:
432 { inherit (u)
433- name uid group description home createHome isSystemUser
434 password passwordFile hashedPassword
435 autoSubUidGidRange subUidRanges subGidRanges
436 initialPassword initialHashedPassword;
···48 services such as SSH, or indirectly via <command>su</command> or
49 <command>sudo</command>). This should only be used for e.g. bootable
50 live systems. Note: this is different from setting an empty password,
51+ which can be achieved using <option>users.users.<name?>.password</option>.
5253 If set to <literal>null</literal> (default) this user will not
54 be able to log in using a password (i.e. via <command>login</command>
···139 description = "The user's home directory.";
140 };
141142+ homeMode = mkOption {
143+ type = types.strMatching "[0-7]{1,5}";
144+ default = "700";
145+ description = "The user's home directory mode in numeric format. See chmod(1). The mode is only applied if <option>users.users.<name>.createHome</option> is true.";
146+ };
147+148 cryptHomeLuks = mkOption {
149 type = with types; nullOr str;
150 default = null;
···325 group = mkDefault "users";
326 createHome = mkDefault true;
327 home = mkDefault "/home/${config.name}";
328+ homeMode = mkDefault "700";
329 useDefaultShell = mkDefault true;
330 isSystemUser = mkDefault false;
331 })
···437 inherit (cfg) mutableUsers;
438 users = mapAttrsToList (_: u:
439 { inherit (u)
440+ name uid group description home homeMode createHome isSystemUser
441 password passwordFile hashedPassword
442 autoSubUidGidRange subUidRanges subGidRanges
443 initialPassword initialHashedPassword;