treewide: create global user list

This commit is contained in:
2026-05-03 18:28:35 -04:00
parent fb9526fec2
commit 1c502afbcd
5 changed files with 64 additions and 58 deletions
+24
View File
@@ -0,0 +1,24 @@
rec {
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 keys" [ ];
users = import ./users.nix;
adminSSHKeys = builtins.concatLists (
map (user: getSSHKeys user.name) (
builtins.filter (user: user.value.admin or false) (attrsToList users)
)
);
}