about summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2020-12-31 02:03:22 +0100
committerGitHub <noreply@github.com>2020-12-31 02:03:22 +0100
commit9206c0d115c2e13767e7b770b903eda9856f78ee (patch)
treeb3f528f64f9ea9b3f3efd33cb686bf3154d44ae7 /nixos/modules/config
parent7da8c4439d9e34ea5c9ad2b140c7899b2ccf7d31 (diff)
parenta709b1a373b4d6c183c72da1294f5cad53a4f80d (diff)
Merge pull request #41966 from aneeshusa/allow-mutable-shells-for-declarative-users
nixos/users: Allow mutable shells for declarative users
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/update-users-groups.pl9
-rw-r--r--nixos/modules/config/users-groups.nix2
2 files changed, 10 insertions, 1 deletions
diff --git a/nixos/modules/config/update-users-groups.pl b/nixos/modules/config/update-users-groups.pl
index 7582371529321..44040217b0271 100644
--- a/nixos/modules/config/update-users-groups.pl
+++ b/nixos/modules/config/update-users-groups.pl
@@ -227,6 +227,15 @@ foreach my $u (@{$spec->{users}}) {
         $u->{hashedPassword} = hashPassword($u->{password});
     }
 
+    if (!defined $u->{shell}) {
+        if (defined $existing) {
+            $u->{shell} = $existing->{shell};
+        } else {
+            warn "warning: no declarative or previous shell for ‘$name’, setting shell to nologin\n";
+            $u->{shell} = "/run/current-system/sw/bin/nologin";
+        }
+    }
+
     $u->{fakePassword} = $existing->{fakePassword} // "x";
     $usersOut{$name} = $u;
 
diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix
index a957633809864..e90a7d567d42c 100644
--- a/nixos/modules/config/users-groups.nix
+++ b/nixos/modules/config/users-groups.nix
@@ -153,7 +153,7 @@ let
       };
 
       shell = mkOption {
-        type = types.either types.shellPackage types.path;
+        type = types.nullOr (types.either types.shellPackage types.path);
         default = pkgs.shadow;
         defaultText = "pkgs.shadow";
         example = literalExample "pkgs.bashInteractive";