nixos-config/modules/common/users.nix

37 lines
864 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; };
enableHomeManagerProfile = mkOption {
type = types.bool;
default = false;
};
2024-04-11 20:15:47 +02:00
homeManagerConfig = mkOption { default = { }; };
};
};
in
{
2024-04-11 20:15:47 +02:00
options.machineUsers = 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;
}) config.machineUsers;
};
}