treewide: create global user list

This commit is contained in:
2026-05-03 18:28:35 -04:00
parent 8f7c2bb8f6
commit c582e557ac
5 changed files with 60 additions and 48 deletions
+21
View File
@@ -0,0 +1,21 @@
rec {
users = import ./users.nix;
adminSSHKeys = builtins.concatLists (
map (user: getSSHKeys user.name) (
builtins.filter (user: user.value.options.admin or false) (attrsToList users)
)
);
attrsToList = mapAttrsToList nameValuePair;
mapAttrsToList = f: attrs: builtins.attrValues (builtins.mapAttrs f attrs);
nameValuePair = name: value: { inherit name value; };
toList = x: if builtins.isList x then x else [ x ];
getSSHKeys =
username:
if (builtins.hasAttr "ssh" users.${username}) then
toList users.${username}.ssh
else
builtins.warn "user ${username} declared without ssh key" [ ];
}