2023-10-22 17:12:42 +02:00
|
|
|
{ lib, config, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
userModule = types.submodule {
|
|
|
|
options = {
|
2024-04-11 20:15:47 +02:00
|
|
|
description = mkOption { type = types.str; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
groups = mkOption { type = types.listOf types.str; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
uid = mkOption { type = types.nullOr types.int; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
shell = mkOption { type = types.package; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
|
|
|
enableHomeManagerProfile = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
homeManagerConfig = mkOption { default = { }; };
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2024-04-11 20:15:47 +02:00
|
|
|
options.machineUsers = mkOption { type = types.attrsOf userModule; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
|
|
|
config = {
|
2024-04-11 20:15:47 +02:00
|
|
|
users.users = builtins.mapAttrs (name: value: {
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/${name}";
|
|
|
|
description = value.description;
|
|
|
|
extraGroups = value.groups;
|
|
|
|
shell = value.shell;
|
|
|
|
uid = mkIf (value.uid != null) value.uid;
|
|
|
|
}) config.machineUsers;
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
}
|