nix-config/nixos/modules/common/users.nix

37 lines
1 KiB
Nix

{ config, lib, ... }:
{
options.homelab.appUsers = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
uid = lib.mkOption {
type = lib.types.int;
description = "The user ID for the app user";
};
group = lib.mkOption {
type = lib.types.str;
default = config.users.groups.apps.name;
description = "The primary group for the app user";
};
extraGroups = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = "Extra groups for the app user";
};
};
});
default = {};
description = "App users to automatically create with standard homelab options";
};
config = {
users.users = lib.mapAttrs (name: cfg: {
uid = lib.mkForce cfg.uid;
isSystemUser = true;
group = cfg.group;
extraGroups = cfg.extraGroups;
home = "/var/empty";
shell = null;
}) config.homelab.appUsers;
};
}