diff options
author | Aneesh Agrawal <aneeshusa@gmail.com> | 2018-06-03 21:01:53 -0700 |
---|---|---|
committer | Aneesh Agrawal <aneeshusa@gmail.com> | 2019-04-07 15:16:01 -0700 |
commit | a709b1a373b4d6c183c72da1294f5cad53a4f80d (patch) | |
tree | 198c1e8d5fa532148564358ae01359773c353b52 /nixos | |
parent | f5ab71ba28784a56b8b4878914ecd6f384ce666e (diff) | |
download | nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.tar nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.tar.gz nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.tar.bz2 nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.tar.lz nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.tar.xz nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.tar.zst nixpkgs-a709b1a373b4d6c183c72da1294f5cad53a4f80d.zip |
nixos/users: Allow mutable shells for declarative users
I want to manage users centrally via declarativeUsers, but allow users to change their shell as they please, similar to how they can change passwords at will if none of the password-related NixOS settings are set for their user.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/config/update-users-groups.pl | 9 | ||||
-rw-r--r-- | nixos/modules/config/users-groups.nix | 2 |
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 ef5e6346f02..57ed9b95be2 100644 --- a/nixos/modules/config/update-users-groups.pl +++ b/nixos/modules/config/update-users-groups.pl @@ -228,6 +228,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 c3f228c9bcc..c50b9829d6d 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -119,7 +119,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"; |