diff options
author | Silvan Mosberger <contact@infinisil.com> | 2021-08-06 01:20:09 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2021-08-08 18:40:06 +0200 |
commit | ea00f991c09c2e77781cbe1e9d72ee1bd632774b (patch) | |
tree | 18fc908932df552cc041ccedc5fa7e015e83761d /nixos/modules/config | |
parent | 88e451423f6ed220190edb026ed7ef453e9c0fa7 (diff) | |
download | nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.tar nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.tar.gz nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.tar.bz2 nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.tar.lz nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.tar.xz nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.tar.zst nixpkgs-ea00f991c09c2e77781cbe1e9d72ee1bd632774b.zip |
nixos/users: Populate group members option
This change makes it so that accessing config.users.groups.*.members isn't empty by default, but instead contains all the users whose `extraGroups` includes that group, allowing fancy things like { config, ... }: { users.groups.libvirt.members = config.users.groups.wheel.members; } to add all users in the wheel group to the libvirt group
Diffstat (limited to 'nixos/modules/config')
-rw-r--r-- | nixos/modules/config/users-groups.nix | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index d5e7745c53f..f86be3be2c6 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -324,7 +324,7 @@ let }; - groupOpts = { name, ... }: { + groupOpts = { name, config, ... }: { options = { @@ -358,6 +358,10 @@ let config = { name = mkDefault name; + + members = mapAttrsToList (n: u: u.name) ( + filterAttrs (n: u: elem config.name u.extraGroups) cfg.users + ); }; }; @@ -419,12 +423,7 @@ let initialPassword initialHashedPassword; shell = utils.toShellPath u.shell; }) 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.users - )); - }) cfg.groups; + groups = attrValues cfg.groups; }); systemShells = |