add first community builder user

This commit is contained in:
Jörg Thalheim 2022-01-09 15:34:55 +01:00
parent 946f59711e
commit 91863124e8
5 changed files with 63 additions and 0 deletions

View file

@ -18,6 +18,7 @@
../roles/common.nix
../roles/hetzner-network.nix
../roles/raid.nix
../roles/users.nix
];
# /boot is a mirror raid

View file

@ -0,0 +1,3 @@
{ ... }: {
imports = [ ./users.nix ];
}

View file

@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuUdiPdq7neZjTSRoc4PuRg8a6M/JBaJ8fjQxPH6uUT 0x4A6F@aarch64-build-box

View file

@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBNvEK+/zeAOuFQiSMSCaY3uSMBy0Fu9IIE16bFgww/o jtojnar+aarch64box@kaiser

57
roles/builder/users.nix Normal file
View file

@ -0,0 +1,57 @@
let
pkgs = import <nixpkgs> {};
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:
#
# youruser = {
# trusted = true;
# keys = ./keys/youruser;
# };
"0x4A6F" = {
trusted = true;
keys = ./keys/0x4A6F;
};
jtojnar = {
trusted = true;
keys = ./keys/jtojnar;
};
};
ifAttr = key: default: result: opts:
if (opts ? "${key}") && opts."${key}"
then result
else default;
maybeTrusted = ifAttr "trusted" [] [ "trusted" ];
maybeWheel = ifAttr "sudo" [] [ "wheel" ];
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
];
};
in {
users = {
groups.trusted = {};
mutableUsers = false;
users = lib.mapAttrs descToUser users;
};
}