refactor: abstract app user creation via custom options
This commit is contained in:
parent
1403b1f9c0
commit
d742671460
7 changed files with 52 additions and 36 deletions
|
|
@ -3,6 +3,7 @@
|
|||
./docker.nix
|
||||
./monitoring.nix
|
||||
./nfs.nix
|
||||
./users.nix
|
||||
];
|
||||
|
||||
config = {
|
||||
|
|
|
|||
37
modules/common/users.nix
Normal file
37
modules/common/users.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ 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;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue