nixos-config/modules/common/users.nix
2024-08-01 21:40:51 +02:00

32 lines
741 B
Nix

{ lib, config, ... }:
with lib;
let
userModule = types.submodule {
options = {
description = mkOption { type = types.str; };
groups = mkOption { type = types.listOf types.str; };
uid = mkOption { type = types.nullOr types.int; };
shell = mkOption { type = types.package; };
hmConfig = mkOption { default = { }; };
};
};
in
{
options.my.users = mkOption { type = types.attrsOf userModule; };
config = {
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.my.users;
};
}