feat(nixos): stalwart mail #129

Merged
nick merged 15 commits from nick/dotfiles:stalwart-mail into main 2026-11-17 23:42:20 -05:00
Owner
No description provided.
nick added 15 commits 2026-11-17 23:42:04 -05:00
The mailboxes and the submission point every service sends through, as
the guest stalwart-prod at mail.nicklab.site, holding nicklab.site and
uprootnutrition.com with their own accounts each. Isaac's private
Stalwart is the model.

The residential WAN can't deliver mail itself: outbound 25 is blocked and
the address is on Spamhaus's PBL (measured 2026-11-17). Everything that
leaves goes through the relay the mail record names, Migadu's submission
port for now; a relay of our own follows.

- network: link stalwart_prod, WAN forwards 25/465/587/993 (reflected
  inside, so services reach the server by its public name), the site for
  the web administrator, whose certificate the guest reads over a share.
- lib/_mail.nix is a record (link, domains, port names, relay) that
  lib/helpers resolves from the network data; every sender switches host
  on its next deploy with no other change.
- secrets: stalwart/* (admin and mailbox passwords with hashes, DKIM keys;
  the noreply@ hashes are of the passwords the services already hold) and
  mx/wireguard-key for the relay box.
- Caddy's site file starts with ready = false (two-deploy rule).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
The MX the internet will talk to, which hands inbound mail to the
Stalwart guest at home and takes its outbound: a Hetzner Cloud box with a
plain ext4 disk through disko, systemd-networkd on its static addresses,
the owner's login, and the tunnel home as tunnel_mail's peer, which
deploy-rs and the ssh feature reach it through (10.1.0.5, mx.internal).
It has no link, so the resolver now lets a host sit on a tunnel alone.
Its Stalwart isn't written yet; the box opens only SSH until then.

docs/mail.md is the runbook: what the WAN allows, the pieces, the secrets,
the DNS records, bringing the guest up, and installing the box with
nixos-anywhere.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
tunnel_mail takes its role's rules, so the relay can ask the firewall for
home's names through the tunnel; with access = "none" every .internal
lookup from it hung. docs/mail.md records what the install of the box
took on 2026-11-17: rescue mode against Ubuntu's kexec lockdown, the
rescale to CX22, disko's udev race and the hand-made filesystems, and
the host keys of each stage.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
The relay is the MX. Its Stalwart listens on 25 with STARTTLS, verifies
every recipient in our domains against the home guest over LMTP through
the tunnel before accepting, queues accepted mail to the guest's new
LMTP listener, signs what the guest submits as the outbound account
(the DKIM keys move to it), and delivers to the world. The guest hands
everything for other domains to the relay at its public name on its
tunnel address, verified against its Let's Encrypt cert, in place of
Migadu. What both Stalwarts share, the 0.15 pin, the administrator, the
memory directory and the writable-config bridge, is features/stalwart.

The guest loses its port 25 and its WAN forward; the tunnel gets a
named port and the two dials; lib/_mail.nix's relay is now the box,
resolved to its tunnel address and port in lib/helpers. The relay's
one login is sops mx/outbound-password, which ceres lends to the guest
under relay-password. docs/mail.md has the records to publish, with
the MX, SPF and TLSA lines, and the bring-up order.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
microvm.nix makes microvm@<guest> Type=notify whenever the guest has a
vsock CID: the guest's PID 1 reports its boot over vsock, through a
socat relay, into the host's notify socket, and the unit stays
activating until READY=1 arrives. The relay loses messages when the
host is busy, which is when every guest boots at once after a deploy.
The guest finishes booting and serves, the host never hears it, the
unit times out after ten minutes, and deploy-rs rolls the whole host
back: five times on ceres in 30 days, tonight's deploy among them,
with the forge's own journal showing "Startup finished" while its unit
sat activating. microvm.nix is already past its socat timing fix.

Every guest unit is now Type=simple. A guest's notify calls fail in
8 ms with nothing listening and its boot is unchanged, measured on a
mars guest. The host no longer waits on a guest's boot; a guest that
boots slowly or not at all shows in its own journal and its services,
not as a host-wide rollback. The ten-minute start timeout and the
socat READY=1 unstick in docs/openbao.md go with it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
The host lends /run/secrets/stalwart at the guest's /run/secrets, so the
staging unit looked one directory too deep and Stalwart never started.
The certificate for mail.nicklab.site was issued on 2026-11-17 20:58,
so the Caddy site serves the name now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
Migadu held five domains and eleven mailboxes (listed over its API on
2026-11-17), and the owner wants them all here. lib/_mail.nix now
carries the mailboxes by domain, and the guest's accounts, the host's
lent secrets and the relay's signers, recipient domains and DKIM keys
all follow from that table, so a new mailbox is a local part in it, a
password and hash in sops, and a deploy. Each domain's first mailbox
answers postmaster@ and abuse@.

New in sops: DKIM keys for compatiq.app, cloudbert.fun and
sensuaistudios.com; passwords and hashes for the eight mailboxes that
didn't exist here (noreply@compatiq.app reuses the backend's SMTP
password, as the other two noreply accounts did). docs/mail.md has the
three domains' records and which senders need the new host.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
The owner no longer holds either registration. Each had one empty
noreply@ mailbox at Migadu; the accounts, their DKIM keys and their
passwords go. docs/mail.md also says why one MX at priority 10 is the
whole set where Migadu had two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
home-manager's Thunderbird module now carries the owner's seven
mailboxes on our Stalwart, at the server and ports the mail record
resolves, in a profile of its own (~/.thunderbird/nick). A rebuild sets
the accounts up; Thunderbird asks for each password once. The parents'
PC moves to a package-only thunderbirdPlain, so none of it lands there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
backendProd/smtp-env and compatiqProd/smtp-env named smtp.migadu.com;
their SMTP_HOST is now mail.nicklab.site, on the same port (587,
STARTTLS) and with the same passwords, which the noreply@ accounts'
hashes were built from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
tunnel_proton_illinois is enabled: the firewall's wg3 now carries the
torrent VM's internet traffic, behind the kill switch and the proton
table's blackhole that were already in place. Every DNS lookup from an
egress link, to whatever resolver, is now rewritten to the tunnel's
resolver and marked into its table, not only lookups aimed at the
firewall, so a guest's fallback resolver can't answer from outside the
VPN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
feat(torrent): no VPN in the guest; the firewall's tunnel is the way out
Some checks failed
CI / build (ceres) (pull_request) Has been cancelled
CI / build (deimos) (pull_request) Has been cancelled
CI / build (eris) (pull_request) Has been cancelled
CI / build (firewall) (pull_request) Has been cancelled
CI / build (lamdagibson) (pull_request) Has been cancelled
CI / build (mars) (pull_request) Has been cancelled
CI / check (pull_request) Has been cancelled
9400b64322
The guest's own Proton tunnel (svpn, through VPN-Confinement) goes:
qBittorrent and slskd run in the VM's main network, which the firewall
sends through Proton alone. The in-guest SYN limit was already the
firewall's synRate. The guest no longer holds the Proton key, and the
host's stable secrets copy drops files it no longer lends. IPv6, the
compiled-in fallback resolvers and link-local name lookups are off. The
vpn-confinement input had no other user.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dB3eMiG93gcJ3PG8jnkqe
nick merged commit 8fb1303ddf into main 2026-11-17 23:42:20 -05:00
nick deleted branch stalwart-mail 2026-11-17 23:42:20 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
upRootNutrition/dotfiles!129
No description provided.