summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authorFederico Beffa <beffa@fbengineering.ch>2022-04-10 21:06:19 +0200
committerFederico Beffa <beffa@fbengineering.ch>2022-04-11 13:16:38 +0200
commit9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7 (patch)
tree28b41ffd2bb580e8c78edd1818eec28fde3d2792 /nixos/modules/config
parent9bce1fb5ac21d52bc37589f1f2586d0f442d63f0 (diff)
downloadnixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.tar
nixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.tar.gz
nixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.tar.bz2
nixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.tar.lz
nixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.tar.xz
nixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.tar.zst
nixpkgs-9fc01af1cc8f9ffe40bf87b96cbafd1810856ea7.zip
nixos/users-group: Add 'homeMode' option.
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/update-users-groups.pl2
-rw-r--r--nixos/modules/config/users-groups.nix9
2 files changed, 9 insertions, 2 deletions
diff --git a/nixos/modules/config/update-users-groups.pl b/nixos/modules/config/update-users-groups.pl
index 26ce561013b..6ceb668a595 100644
--- a/nixos/modules/config/update-users-groups.pl
+++ b/nixos/modules/config/update-users-groups.pl
@@ -226,7 +226,7 @@ foreach my $u (@{$spec->{users}}) {
     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};
+        chmod oct($u->{homeMode}), $u->{home};
     }
 
     if (defined $u->{passwordFile}) {
diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix
index b0f96c754fa..e9ce9d5e411 100644
--- a/nixos/modules/config/users-groups.nix
+++ b/nixos/modules/config/users-groups.nix
@@ -139,6 +139,12 @@ let
         description = "The user's home directory.";
       };
 
+      homeMode = mkOption {
+        type = types.strMatching "[0-7]{1,5}";
+        default = "700";
+        description = "The user's home directory mode in numeric format. See chmod(1).";
+      };
+
       cryptHomeLuks = mkOption {
         type = with types; nullOr str;
         default = null;
@@ -319,6 +325,7 @@ let
           group = mkDefault "users";
           createHome = mkDefault true;
           home = mkDefault "/home/${config.name}";
+          homeMode = mkDefault "700";
           useDefaultShell = mkDefault true;
           isSystemUser = mkDefault false;
         })
@@ -430,7 +437,7 @@ let
     inherit (cfg) mutableUsers;
     users = mapAttrsToList (_: u:
       { inherit (u)
-          name uid group description home createHome isSystemUser
+          name uid group description home homeMode createHome isSystemUser
           password passwordFile hashedPassword
           autoSubUidGidRange subUidRanges subGidRanges
           initialPassword initialHashedPassword;