{ config, lib, ... }:
let
  cfg = config.khscodes.infrastructure.mailserver;
in
{
  config = lib.mkIf cfg.enable {
    khscodes.infrastructure.provisioning.pre.modules = [
      {
        khscodes.cloudflare.dns.txtRecords = lib.lists.map (domain: {
          fqdn = domain;
          content = ''"v=spf1 mx ra=postmaster -all"'';
          ttl = 600;
        }) cfg.domains;
      }
    ];
  };
}
