diff --git a/configs/nixos/ni/default.nix b/configs/nixos/ni/default.nix index b98fb947..1926851d 100644 --- a/configs/nixos/ni/default.nix +++ b/configs/nixos/ni/default.nix @@ -19,6 +19,7 @@ networking.enable = true; services.backup.enable = true; services.monitoring.enable = true; + services.mail-archive.enable = true; services.penpot.enable = true; services.reverse-proxy.enable = true; setups = { diff --git a/configs/nixos/ni/modules/default.nix b/configs/nixos/ni/modules/default.nix index b67caa27..b2b10c24 100644 --- a/configs/nixos/ni/modules/default.nix +++ b/configs/nixos/ni/modules/default.nix @@ -5,6 +5,7 @@ ./networking/setup.nix ./networking/wireguard.nix ./services/backup + ./services/mail-archive.nix ./services/reverse-proxy.nix ./services/monitoring.nix ./services/download-media diff --git a/configs/nixos/ni/modules/services/mail-archive.nix b/configs/nixos/ni/modules/services/mail-archive.nix new file mode 100644 index 00000000..95abc9e2 --- /dev/null +++ b/configs/nixos/ni/modules/services/mail-archive.nix @@ -0,0 +1,89 @@ +{ config, lib, pkgs, ... }: + +let + hostCfg = config.hosts.ni; + cfg = hostCfg.services.mail-archive; + + repos = { + guix-devel = { + description = "Guix development channel"; + address = [ "guix-devel@gnu.org" ]; + newsgroup = "inbox.comp.guix.devel"; + }; + + systemd-devel = { + address = [ "systemd-devel@lists.freedesktop.org" ]; + description = "systemd development channel"; + newsgroup = "inbox.comp.systemd.devel"; + }; + }; +in +{ + options.hosts.ni.services.mail-archive.enable = + lib.mkEnableOption "preferred mail archiving service"; + + config = lib.mkIf cfg.enable { + state.ports.public-inbox-httpd.value = 23456; + + services.public-inbox = { + enable = true; + http = { + enable = true; + port = "/run/public-inbox-http.sock"; + mounts = [ + "https://mail.ni.internal/inbox" + ]; + }; + imap.enable = true; + nntp.enable = true; + + path = with pkgs; [ spamassassin ]; + + inboxes = lib.mapAttrs (n: v: { + inherit (v) description address newsgroup; + url = "http://mail.ni.internal/inbox/${n}"; + coderepo = [ n ]; + }) repos; + + settings.coderepo = lib.mapAttrs (n: v: { + dir = "/var/lib/gitea/"; + cgitUrl = "http://git.ni.internal/${n}.git"; + }) repos; + }; + + services.nginx.virtualHosts."mail.ni.internal" = { + locations."/".return = "302 /inbox"; + locations."= /inbox".return = "302 /inbox/"; + locations."/inbox".proxyPass = "http://unix:${config.services.public-inbox.http.port}:/inbox"; + locations."= /style/light.css".alias = pkgs.writeText "light.css" '' + * { background:#fff; color:#000 } + + a { color:#00f; text-decoration:none } + a:visited { color:#808 } + + *.q { color:#008 } + + *.add { color:#060 } + *.del {color:#900 } + *.head { color:#000 } + *.hunk { color:#960 } + + .hl.num { color:#f30 } /* number */ + .hl.esc { color:#f0f } /* escape character */ + .hl.str { color:#f30 } /* string */ + .hl.ppc { color:#c3c } /* preprocessor */ + .hl.pps { color:#f30 } /* preprocessor string */ + .hl.slc { color:#099 } /* single-line comment */ + .hl.com { color:#099 } /* multi-line comment */ + /* .hl.opt { color:#ccc } */ /* operator */ + /* .hl.ipl { color:#ccc } */ /* interpolation */ + + /* keyword groups kw[a-z] */ + .hl.kwa { color:#f90 } + .hl.kwb { color:#060 } + .hl.kwc { color:#f90 } + /* .hl.kwd { color:#ccc } */ + ''; + }; + }; +}