{ config, lib, ... }:
{
  imports = [ ./nginx ];

  services = lib.mkIf config.services.mailserver.enable {
    go-autoconfig = {
      enable = true;
      settings = {
        service_addr = ":1323";
        domain = "autoconfig.nixfox.ca";
        imap = {
          server = "mx.nixfox.ca";
          port = 143;
        };
        smtp = {
          server = "mx.nixfox.ca";
          port = 587;
        };
      };
    };
    cloudflare-dyndns.domains = [ config.services.go-autoconfig.settings.domain ];
  };
}
