Merge pull request #41966 from aneeshusa/allow-mutable-shells-for-declarative-users

nixos/users: Allow mutable shells for declarative users
This commit is contained in:
Niklas Hambüchen 2020-12-31 02:03:22 +01:00 committed by GitHub
commit 9206c0d115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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;

View File

@ -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";