NixOS configuration 馃獎
1{ lib, ... }:
2let
3 inherit (lib.lists) any;
4 inherit (lib) optionals forEach;
5
6 # Search in a list of users, who of these users are in a specific group
7 # If the user has at least one of these groups, return true
8 # inGroup :: array -> string -> bool
9 hasGroup = groups: user: any (group: builtins.elem group user.extraGroups) groups;
10
11 # Filters an array of usernames, leaving only the ones with root access
12 # Uses the from above created "hasGroup"
13 # filterTrustedUsers :: array -> array
14 filterTrustedUsers =
15 users: config:
16 forEach users (user: optionals (hasGroup [ "wheel" ] config.users.users.${user}) user);
17
18in
19{
20 inherit hasGroup filterTrustedUsers;
21}