treewide: create global user list
This commit is contained in:
+8
-40
@@ -1,25 +1,6 @@
|
||||
{ lib, self, ... }:
|
||||
let
|
||||
users = [
|
||||
{
|
||||
name = "error";
|
||||
options.admin = true;
|
||||
}
|
||||
{
|
||||
name = "javalsai";
|
||||
options.admin = true;
|
||||
}
|
||||
{
|
||||
name = "max";
|
||||
options.admin = true;
|
||||
}
|
||||
{
|
||||
name = "vectorum";
|
||||
}
|
||||
{
|
||||
name = "pickzelle";
|
||||
}
|
||||
];
|
||||
inherit (self.lib) users;
|
||||
|
||||
adminGroups = [
|
||||
"adm"
|
||||
@@ -30,29 +11,17 @@ let
|
||||
"wheel"
|
||||
];
|
||||
|
||||
getSSHKeys =
|
||||
username:
|
||||
let
|
||||
sshKeys = import "${self}/lib/ssh/keys.nix";
|
||||
in
|
||||
if (builtins.hasAttr username sshKeys) then
|
||||
lib.lists.toList sshKeys.${username}
|
||||
else
|
||||
lib.warn "user ${username} declared without ssh key" [ ];
|
||||
|
||||
mkUser =
|
||||
name: uid: options:
|
||||
let
|
||||
admin = options.admin or false;
|
||||
|
||||
in
|
||||
{
|
||||
users.users.${name} = {
|
||||
inherit uid;
|
||||
isNormalUser = true;
|
||||
extraGroups = lib.optionals admin adminGroups;
|
||||
inherit uid;
|
||||
|
||||
openssh.authorizedKeys.keys = getSSHKeys name;
|
||||
openssh.authorizedKeys.keys = self.lib.getSSHKeys name;
|
||||
};
|
||||
|
||||
systemd.slices."user-${builtins.toString uid}".sliceConfig = {
|
||||
@@ -69,21 +38,20 @@ in
|
||||
lib.recursiveUpdate
|
||||
(builtins.foldl'
|
||||
(attrs: user: {
|
||||
options = lib.recursiveUpdate attrs.options (mkUser user.name attrs.uid (user.options or { }));
|
||||
options = lib.recursiveUpdate attrs.options (
|
||||
mkUser user.name attrs.uid (user.value.options or { })
|
||||
);
|
||||
uid = attrs.uid + 1;
|
||||
})
|
||||
{
|
||||
options = { };
|
||||
uid = 1000;
|
||||
}
|
||||
users
|
||||
(lib.attrsToList users)
|
||||
).options
|
||||
{
|
||||
users.users.root = {
|
||||
initialPassword = "tuxcord";
|
||||
|
||||
openssh.authorizedKeys.keys = lib.lists.concatLists (
|
||||
map (user: getSSHKeys user.name) (builtins.filter (user: user.options.admin or false) users)
|
||||
);
|
||||
openssh.authorizedKeys.keys = self.lib.adminSSHKeys;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user