nixos-config/modules/common/users.nix

32 lines
741 B
Nix
Raw Normal View History

{ lib, config, ... }:
with lib;
let
userModule = types.submodule {
options = {
2024-04-11 20:15:47 +02:00
description = mkOption { type = types.str; };
2024-04-11 20:15:47 +02:00
groups = mkOption { type = types.listOf types.str; };
2024-04-11 20:15:47 +02:00
uid = mkOption { type = types.nullOr types.int; };
2024-04-11 20:15:47 +02:00
shell = mkOption { type = types.package; };
2024-08-01 21:40:51 +02:00
hmConfig = mkOption { default = { }; };
};
};
in
{
2024-08-01 21:40:51 +02:00
options.my.users = mkOption { type = types.attrsOf userModule; };
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;
};
}