Redirecting mail with NixOS & Postfix

A while ago I bought a really short domain name—23p.org—because I thought it would be handy for writing my email on forms, and spelling it over the phone. “j@23p.org” is much easier to write than “nornagon@nornagon.net”, which is the canonical address I use everywhere else.

It turns out though that GMail isn't really expecting you to do this with your email, and doesn't have any options for receiving mail on alternative domains. No matter, I thought, I'll just set up a mail redirection! How hard could it be?

It turns out, all mail software is ancient and arcane. There are at least three different mail server systems, and most of the guides on how to set them up expect you to be using them as an actual mail server. I just wanted to redirect mail, not to store it or host IMAP or any other mysterious and ineffable e-mail nonsense.

Years ago, I had all this set up on a Linode running Debian, but I shut down all my cloud servers this year and I'm now hosting all my Internet-facing things from a NUC in my closet running NixOS. So I had to figure out how to get Postfix configured again.

It turned out to be pretty easy! Here's the configuration I used:

  services.postfix = {
    enable = true;
    hostname = "23p.org";
    domain = "23p.org";
    virtual = "j@23p.org nornagon@nornagon.net";
  };

  networking.firewall.allowedTCPPorts = [25];

And the DNS records to go along with it (home.nornagon.net points to my home IP):

@ MX 10 home.nornagon.net