Skip to content

Commit

Permalink
Rename users.extraUsers -> users.users, users.extraGroup -> users.groups
Browse files Browse the repository at this point in the history
The "extra" part hasn't made sense for years.
  • Loading branch information
edolstra committed Sep 2, 2015
1 parent dc5bf39 commit 14321ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
32 changes: 16 additions & 16 deletions nixos/modules/config/users-groups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ let
map (range: "${user.name}:${toString range.startUid}:${toString range.count}\n")
user.subUidRanges);

subuidFile = concatStrings (map mkSubuidEntry (attrValues cfg.extraUsers));
subuidFile = concatStrings (map mkSubuidEntry (attrValues cfg.users));

mkSubgidEntry = user: concatStrings (
map (range: "${user.name}:${toString range.startGid}:${toString range.count}\n")
user.subGidRanges);

subgidFile = concatStrings (map mkSubgidEntry (attrValues cfg.extraUsers));
subgidFile = concatStrings (map mkSubgidEntry (attrValues cfg.users));

idsAreUnique = set: idAttr: !(fold (name: args@{ dup, acc }:
let
Expand All @@ -354,8 +354,8 @@ let
else { dup = false; acc = newAcc; }
) { dup = false; acc = {}; } (builtins.attrNames set)).dup;

uidsAreUnique = idsAreUnique (filterAttrs (n: u: u.uid != null) cfg.extraUsers) "uid";
gidsAreUnique = idsAreUnique (filterAttrs (n: g: g.gid != null) cfg.extraGroups) "gid";
uidsAreUnique = idsAreUnique (filterAttrs (n: u: u.uid != null) cfg.users) "uid";
gidsAreUnique = idsAreUnique (filterAttrs (n: g: g.gid != null) cfg.groups) "gid";

spec = pkgs.writeText "users-groups.json" (builtins.toJSON {
inherit (cfg) mutableUsers;
Expand All @@ -364,13 +364,13 @@ let
name uid group description home shell createHome isSystemUser
password passwordFile hashedPassword
initialPassword initialHashedPassword;
}) cfg.extraUsers;
}) cfg.users;
groups = mapAttrsToList (n: g:
{ inherit (g) name gid;
members = g.members ++ (mapAttrsToList (n: u: u.name) (
filterAttrs (n: u: elem g.name u.extraGroups) cfg.extraUsers
filterAttrs (n: u: elem g.name u.extraGroups) cfg.users
));
}) cfg.extraGroups;
}) cfg.groups;
});

in {
Expand All @@ -388,18 +388,18 @@ in {
<literal>groupadd</literal> commands. On system activation, the
existing contents of the <literal>/etc/passwd</literal> and
<literal>/etc/group</literal> files will be merged with the
contents generated from the <literal>users.extraUsers</literal> and
<literal>users.extraGroups</literal> options.
contents generated from the <literal>users.users</literal> and
<literal>users.groups</literal> options.
The initial password for a user will be set
according to <literal>users.extraUsers</literal>, but existing passwords
according to <literal>users.users</literal>, but existing passwords
will not be changed.
<warning><para>
If set to <literal>false</literal>, the contents of the user and
group files will simply be replaced on system activation. This also
holds for the user passwords; all changed
passwords will be reset according to the
<literal>users.extraUsers</literal> configuration on activation.
<literal>users.users</literal> configuration on activation.
</para></warning>
'';
};
Expand All @@ -412,7 +412,7 @@ in {
'';
};

users.extraUsers = mkOption {
users.users = mkOption {
default = {};
type = types.loaOf types.optionSet;
example = {
Expand All @@ -433,7 +433,7 @@ in {
options = [ userOpts ];
};

users.extraGroups = mkOption {
users.groups = mkOption {
default = {};
example =
{ students.gid = 1001;
Expand Down Expand Up @@ -461,7 +461,7 @@ in {

config = {

users.extraUsers = {
users.users = {
root = {
uid = ids.uids.root;
description = "System administrator";
Expand All @@ -478,7 +478,7 @@ in {
};
};

users.extraGroups = {
users.groups = {
root.gid = ids.gids.root;
wheel.gid = ids.gids.wheel;
disk.gid = ids.gids.disk;
Expand Down Expand Up @@ -541,7 +541,7 @@ in {
|| cfg.passwordFile != null
|| cfg.openssh.authorizedKeys.keys != []
|| cfg.openssh.authorizedKeys.keyFiles != [])
) cfg.extraUsers);
) cfg.users);
message = ''
Neither the root account nor any wheel user has a password or SSH authorized key.
You must set one to prevent being locked out of your system.'';
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/rename.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ in zipModules ([]
++ obsolete [ "environment" "nix" ] [ "nix" "package" ]
++ obsolete [ "fonts" "enableFontConfig" ] [ "fonts" "fontconfig" "enable" ]
++ obsolete [ "fonts" "extraFonts" ] [ "fonts" "fonts" ]
++ alias [ "users" "extraUsers" ] [ "users" "users" ]
++ alias [ "users" "extraGroups" ] [ "users" "groups" ]

++ obsolete [ "security" "extraSetuidPrograms" ] [ "security" "setuidPrograms" ]
++ obsolete [ "networking" "enableWLAN" ] [ "networking" "wireless" "enable" ]
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/networking/ssh/sshd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ in

};

users.extraUsers = mkOption {
users.users = mkOption {
options = [ userOptions ];
};

Expand Down

0 comments on commit 14321ae

Please sign in to comment.