mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 17:03:01 +00:00
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>
|
||||
users.extraUsers.alice =
|
||||
{ createHome = true;
|
||||
home = "/home/alice";
|
||||
{ isNormalUser = true;
|
||||
description = "Alice Foobar";
|
||||
extraGroups = [ "wheel" "networkmanager" ];
|
||||
useDefaultShell = true;
|
||||
openssh.authorizedKeys.keys = [ "ssh-dss AAAAB3Nza... alice@foobar" ];
|
||||
};
|
||||
</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 {
|
||||
type = types.str;
|
||||
default = "nogroup";
|
||||
@ -148,10 +163,18 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
name = mkDefault name;
|
||||
shell = mkIf config.useDefaultShell (mkDefault cfg.defaultUserShell);
|
||||
};
|
||||
config = mkMerge
|
||||
[ { name = mkDefault name;
|
||||
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’.
|
||||
# users.extraUsers.guest = {
|
||||
# name = "guest";
|
||||
# group = "users";
|
||||
# isNormalUser = true;
|
||||
# uid = 1000;
|
||||
# createHome = true;
|
||||
# home = "/home/guest";
|
||||
# shell = "/run/current-system/sw/bin/bash";
|
||||
# };
|
||||
|
||||
}
|
||||
|
@ -4,12 +4,9 @@
|
||||
imports = [ ./graphical.nix ];
|
||||
|
||||
users.extraUsers.demo =
|
||||
{ description = "Demo user account";
|
||||
group = "users";
|
||||
{ isNormalUser = true;
|
||||
description = "Demo user account";
|
||||
extraGroups = [ "wheel" ];
|
||||
home = "/home/demo";
|
||||
createHome = true;
|
||||
useDefaultShell = true;
|
||||
password = "demo";
|
||||
uid = 1000;
|
||||
};
|
||||
|
@ -1,11 +1,9 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{ users.extraUsers = pkgs.lib.singleton
|
||||
{ name = "alice";
|
||||
{ isNormalUser = true;
|
||||
name = "alice";
|
||||
description = "Alice Foobar";
|
||||
home = "/home/alice";
|
||||
createHome = true;
|
||||
useDefaultShell = true;
|
||||
password = "foobar";
|
||||
uid = 1000;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user