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
|
|
|
|
2024-08-01 21:40:51 +02:00
|
|
|
hmConfig = mkOption { default = { }; };
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2024-08-01 21:40:51 +02:00
|
|
|
options.my.users = 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;
|
2024-08-01 21:40:51 +02:00
|
|
|
}) config.my.users;
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
}
|