2023-09-11 20:23:04 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
fn,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-11-20 20:32:38 +01:00
|
|
|
with lib;
|
|
|
|
let
|
2023-06-14 21:52:10 +02:00
|
|
|
withDocker = config.virtualisation.docker.enable;
|
|
|
|
withPodman = config.virtualisation.podman.enable;
|
2019-04-13 00:05:39 +02:00
|
|
|
administrators = user: {
|
2023-09-11 21:20:14 +02:00
|
|
|
inherit (user) name;
|
2024-11-20 20:32:38 +01:00
|
|
|
value =
|
|
|
|
let
|
|
|
|
cfg = config.services;
|
|
|
|
passPath = config.sops.secrets."users/${user.name}/password".path;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
isNormalUser = true;
|
|
|
|
inherit (user) name;
|
|
|
|
uid = user.id;
|
|
|
|
subUidRanges = optional withPodman {
|
|
|
|
startUid = 100000;
|
|
|
|
count = 65536;
|
|
|
|
};
|
|
|
|
subGidRanges = optional withPodman {
|
|
|
|
startGid = 100000;
|
|
|
|
count = 65536;
|
|
|
|
};
|
|
|
|
home = builtins.toPath "/home/${user.name}";
|
|
|
|
createHome = true;
|
|
|
|
description = "Administrative user ${user.name}.";
|
|
|
|
group = user.name;
|
|
|
|
extraGroups =
|
|
|
|
[
|
|
|
|
"audio"
|
|
|
|
"wheel"
|
|
|
|
"network"
|
|
|
|
]
|
|
|
|
++ (optionals (lib.elem "desktop" config.machine.services) [
|
|
|
|
"input"
|
|
|
|
"video"
|
|
|
|
])
|
|
|
|
++ (optionals cfg.printing.enable [
|
|
|
|
"cups"
|
|
|
|
"lp"
|
|
|
|
])
|
2024-12-07 22:53:20 +01:00
|
|
|
++ (optional config.programs.virt-manager.enable "libvirtd")
|
2024-11-20 20:32:38 +01:00
|
|
|
++ (optional (withDocker && !withPodman) "docker")
|
|
|
|
++ (optional withPodman "podman");
|
|
|
|
shell = "${pkgs.zsh}/bin/zsh";
|
|
|
|
hashedPasswordFile = passPath;
|
2023-09-11 20:23:04 +02:00
|
|
|
};
|
2019-04-13 00:05:39 +02:00
|
|
|
};
|
2019-03-23 02:50:48 +01:00
|
|
|
|
2023-09-11 20:23:04 +02:00
|
|
|
mkusergroup = user: {
|
2023-09-11 21:20:14 +02:00
|
|
|
inherit (user) name;
|
2023-09-11 20:23:04 +02:00
|
|
|
value = {
|
2023-09-11 21:20:14 +02:00
|
|
|
inherit (user) name;
|
2023-09-11 20:23:04 +02:00
|
|
|
gid = user.id;
|
2024-11-20 20:32:38 +01:00
|
|
|
members = [ user.name ];
|
2023-09-11 20:23:04 +02:00
|
|
|
};
|
|
|
|
};
|
2024-11-20 20:32:38 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
sops.secrets = fn.sopsHelper (user: "users/${user.name}/password") config.machine.administrators {
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
2019-04-13 00:05:39 +02:00
|
|
|
users = {
|
|
|
|
mutableUsers = false;
|
|
|
|
users = listToAttrs (map administrators config.machine.administrators);
|
|
|
|
groups = listToAttrs (map mkusergroup config.machine.administrators);
|
2019-02-26 13:44:40 +01:00
|
|
|
};
|
|
|
|
}
|