Add autodiscovery to the mailserver

This commit is contained in:
Jimbo 2025-03-03 03:41:49 -05:00
parent 4a18eccddd
commit f428198857
4 changed files with 39 additions and 7 deletions

View file

@ -3,6 +3,7 @@
options.system.mailserver.enable = lib.mkEnableOption "Enable Simple NixOS Mailserver";
imports = [
./go-autoconfig
./roundcube
./simplenix
];

View file

@ -0,0 +1,20 @@
{ config, ... }:
{
imports = [ ./nginx ];
services.go-autoconfig = {
enable = config.system.mailserver.enable;
settings = {
service_addr = ":1323";
domain = "autoconfig.nixfox.ca";
imap = {
server = "mx.nixfox.ca";
port = 143;
};
smtp = {
server = "mx.nixfox.ca";
port = 587;
};
};
};
}

View file

@ -0,0 +1,11 @@
{ config, lib, ... }:
{
services.nginx.virtualHosts."autoconfig.nixfox.ca" = lib.mkIf config.mailserver.enable {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:1323";
proxyWebsockets = true;
};
};
}

View file

@ -1,12 +1,12 @@
{ config, ... }:
{
services.roundcube = {
enable = config.system.mailserver.enable;
hostName = "mail.nixfox.ca";
extraConfig = ''
$config['smtp_server'] = "tls://mx.nixfox.ca";
$config['smtp_user'] = "%u";
$config['smtp_pass'] = "%p";
'';
enable = config.system.mailserver.enable;
hostName = "mail.nixfox.ca";
extraConfig = ''
$config['smtp_server'] = "tls://mx.nixfox.ca";
$config['smtp_user'] = "%u";
$config['smtp_pass'] = "%p";
'';
};
}