nixos-config/modules/common/users.nix
2024-04-11 20:33:12 +02:00

37 lines
864 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; };
enableHomeManagerProfile = mkOption {
type = types.bool;
default = false;
};
homeManagerConfig = mkOption { default = { }; };
};
};
in
{
options.machineUsers = 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.machineUsers;
};
}