···223223 }
224224225225 # Ensure home directory incl. ownership and permissions.
226226- if ($u->{createHome}) {
227227- make_path($u->{home}, { mode => 0700 }) if ! -e $u->{home} and ! $is_dry;
226226+ if ($u->{createHome} and !$is_dry) {
227227+ make_path($u->{home}, { mode => oct($u->{homeMode}) }) if ! -e $u->{home};
228228 chown $u->{uid}, $u->{gid}, $u->{home};
229229- chmod 0700, $u->{home};
229229+ chmod oct($u->{homeMode}), $u->{home};
230230 }
231231232232 if (defined $u->{passwordFile}) {
+9-2
nixos/modules/config/users-groups.nix
···4848 services such as SSH, or indirectly via <command>su</command> or
4949 <command>sudo</command>). This should only be used for e.g. bootable
5050 live systems. Note: this is different from setting an empty password,
5151- which ca be achieved using <option>users.users.<name?>.password</option>.
5151+ which can be achieved using <option>users.users.<name?>.password</option>.
52525353 If set to <literal>null</literal> (default) this user will not
5454 be able to log in using a password (i.e. via <command>login</command>
···139139 description = "The user's home directory.";
140140 };
141141142142+ homeMode = mkOption {
143143+ type = types.strMatching "[0-7]{1,5}";
144144+ default = "700";
145145+ 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.";
146146+ };
147147+142148 cryptHomeLuks = mkOption {
143149 type = with types; nullOr str;
144150 default = null;
···319325 group = mkDefault "users";
320326 createHome = mkDefault true;
321327 home = mkDefault "/home/${config.name}";
328328+ homeMode = mkDefault "700";
322329 useDefaultShell = mkDefault true;
323330 isSystemUser = mkDefault false;
324331 })
···430437 inherit (cfg) mutableUsers;
431438 users = mapAttrsToList (_: u:
432439 { inherit (u)
433433- name uid group description home createHome isSystemUser
440440+ name uid group description home homeMode createHome isSystemUser
434441 password passwordFile hashedPassword
435442 autoSubUidGidRange subUidRanges subGidRanges
436443 initialPassword initialHashedPassword;