mailsystem: Add vmail user and group configuration

This commit is contained in:
Thomas Preisner 2024-12-06 16:41:06 +01:00
parent 9180d7345c
commit 56feea5754
2 changed files with 47 additions and 0 deletions

View file

@ -13,9 +13,34 @@
example = "mail.example.com";
description = "Fully qualified domain name of the mail server.";
};
vmailUID = lib.mkOption {
type = lib.types.int;
default = 5000;
description = "The unix UID of the virtual mail user.";
};
vmailUserName = lib.mkOption {
type = lib.types.str;
default = "vmail";
description = "The user name of the user that owns the directory all the mail is stored.";
};
vmailGroupName = lib.mkOption {
type = lib.types.str;
default = "vmail";
description = "The group name of the user that owns the directory all the mail is stored.";
};
mailDirectory = lib.mkOption {
type = lib.types.str;
default = "/var/vmail";
description = "Storage location for all mail.";
};
};
imports = [
./nginx.nix
./user.nix
];
}

22
mailsystem/user.nix Normal file
View file

@ -0,0 +1,22 @@
{
config,
lib,
...
}: let
cfg = config.mailsystem;
in {
config = lib.mkIf cfg.enable {
users.users."${cfg.vmailUserName}" = {
uid = cfg.vmailUID;
isSystemUser = true;
group = cfg.vmailGroupName;
home = cfg.mailDirectory;
createHome = true;
description = "Virtual Mail User";
};
users.groups."${cfg.vmailGroupName}" = {
gid = cfg.vmailUID;
};
};
}