diff --git a/mailsystem/default.nix b/mailsystem/default.nix index 886e5e2..abc5b73 100644 --- a/mailsystem/default.nix +++ b/mailsystem/default.nix @@ -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 ]; } diff --git a/mailsystem/user.nix b/mailsystem/user.nix new file mode 100644 index 0000000..416d20d --- /dev/null +++ b/mailsystem/user.nix @@ -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; + }; + }; +}