Add user attribute isNormalUser
This is shorthand for setting group, createHome, home, useDefaultShell and isSystemUser.
This commit is contained in:
parent
1a75958be5
commit
a323d146b7
@ -1033,11 +1033,9 @@ states that a user account named <literal>alice</literal> shall exist:
|
|||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
users.extraUsers.alice =
|
users.extraUsers.alice =
|
||||||
{ createHome = true;
|
{ isNormalUser = true;
|
||||||
home = "/home/alice";
|
|
||||||
description = "Alice Foobar";
|
description = "Alice Foobar";
|
||||||
extraGroups = [ "wheel" "networkmanager" ];
|
extraGroups = [ "wheel" "networkmanager" ];
|
||||||
useDefaultShell = true;
|
|
||||||
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
|
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
|
||||||
};
|
};
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@ -70,6 +70,21 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
isNormalUser = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Indicates whether this is an account for a “real” user. This
|
||||||
|
automatically sets <option>group</option> to
|
||||||
|
<literal>users</literal>, <option>createHome</option> to
|
||||||
|
<literal>true</literal>, <option>home</option> to
|
||||||
|
<filename>/home/<replaceable>username</replaceable></filename>,
|
||||||
|
<option>useDefaultShell</option> to <literal>true</literal>,
|
||||||
|
and <option>isSystemUser</option> to
|
||||||
|
<literal>false</literal>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "nogroup";
|
default = "nogroup";
|
||||||
@ -148,10 +163,18 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = mkMerge
|
||||||
name = mkDefault name;
|
[ { name = mkDefault name;
|
||||||
shell = mkIf config.useDefaultShell (mkDefault cfg.defaultUserShell);
|
shell = mkIf config.useDefaultShell (mkDefault cfg.defaultUserShell);
|
||||||
};
|
}
|
||||||
|
(mkIf config.isNormalUser {
|
||||||
|
group = mkDefault "users";
|
||||||
|
createHome = mkDefault true;
|
||||||
|
home = mkDefault "/home/${name}";
|
||||||
|
useDefaultShell = mkDefault true;
|
||||||
|
isSystemUser = mkDefault false;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -490,12 +490,8 @@ $bootLoaderConfig
|
|||||||
|
|
||||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||||
# users.extraUsers.guest = {
|
# users.extraUsers.guest = {
|
||||||
# name = "guest";
|
# isNormalUser = true;
|
||||||
# group = "users";
|
|
||||||
# uid = 1000;
|
# uid = 1000;
|
||||||
# createHome = true;
|
|
||||||
# home = "/home/guest";
|
|
||||||
# shell = "/run/current-system/sw/bin/bash";
|
|
||||||
# };
|
# };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,9 @@
|
|||||||
imports = [ ./graphical.nix ];
|
imports = [ ./graphical.nix ];
|
||||||
|
|
||||||
users.extraUsers.demo =
|
users.extraUsers.demo =
|
||||||
{ description = "Demo user account";
|
{ isNormalUser = true;
|
||||||
group = "users";
|
description = "Demo user account";
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
home = "/home/demo";
|
|
||||||
createHome = true;
|
|
||||||
useDefaultShell = true;
|
|
||||||
password = "demo";
|
password = "demo";
|
||||||
uid = 1000;
|
uid = 1000;
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
{ users.extraUsers = pkgs.lib.singleton
|
{ users.extraUsers = pkgs.lib.singleton
|
||||||
{ name = "alice";
|
{ isNormalUser = true;
|
||||||
|
name = "alice";
|
||||||
description = "Alice Foobar";
|
description = "Alice Foobar";
|
||||||
home = "/home/alice";
|
|
||||||
createHome = true;
|
|
||||||
useDefaultShell = true;
|
|
||||||
password = "foobar";
|
password = "foobar";
|
||||||
uid = 1000;
|
uid = 1000;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user