infra/modules/nixos/community-builder/users.nix

90 lines
1.6 KiB
Nix
Raw Normal View History

2022-01-09 15:40:38 +01:00
{ pkgs, ... }:
2022-01-09 15:34:55 +01:00
let
inherit (pkgs) lib;
users = {
# 1. Generate an SSH key for your root account and add the public
# key to a file matching your name in ./keys/
#
# 2. Copy / paste this in order, alphabetically:
#
2022-01-16 10:23:57 -05:00
# youruser.keys = ./keys/youruser;
#
2022-01-09 15:34:55 +01:00
"0x4A6F" = {
trusted = true;
keys = ./keys/0x4A6F;
};
2022-09-27 13:15:23 +02:00
a-kenji = {
trusted = true;
keys = ./keys/a-kenji;
};
ckie.keys = ./keys/ckie;
2022-08-22 14:01:20 +02:00
fgaz = {
trusted = true;
keys = ./keys/fgaz;
};
flokli = {
trusted = true;
keys = ./keys/flokli;
};
2022-01-09 15:34:55 +01:00
jtojnar = {
trusted = true;
keys = ./keys/jtojnar;
};
2022-01-16 10:23:57 -05:00
lewo = {
trusted = true;
keys = ./keys/lewo;
};
raitobezarius = {
trusted = true;
keys = ./keys/raitobezarius;
};
2022-12-31 07:24:17 +01:00
2022-09-18 14:48:18 +02:00
schmittlauch = {
trusted = true;
keys = ./keys/schmittlauch;
};
2022-08-30 01:51:22 +02:00
2023-04-23 11:33:59 +02:00
stephank.keys = ./keys/stephank;
2022-01-16 10:23:57 -05:00
winter.keys = ./keys/winter;
2022-01-09 15:34:55 +01:00
};
ifAttr = key: default: result: opts:
if (opts ? "${key}") && opts."${key}"
2022-08-14 16:49:30 +02:00
then result
else default;
2022-01-09 15:34:55 +01:00
2022-08-14 16:49:30 +02:00
maybeTrusted = ifAttr "trusted" [ ] [ "trusted" ];
maybeWheel = ifAttr "sudo" [ ] [ "wheel" ];
2022-01-09 15:34:55 +01:00
userGroups = opts:
(maybeTrusted opts) ++
(maybeWheel opts);
descToUser = name: opts:
{
isNormalUser = true;
extraGroups = userGroups opts;
createHome = true;
home = "/home/${name}";
hashedPassword = opts.password or null;
openssh.authorizedKeys.keyFiles = [
opts.keys
];
};
2022-08-14 16:49:30 +02:00
in
{
2022-01-09 15:34:55 +01:00
users = {
mutableUsers = false;
users = lib.mapAttrs descToUser users;
};
}