about summary refs log tree commit diff
path: root/modules/server/mail/public-inbox/default.nix
blob: 10cf46387702aafafbf87bd3b7f6039463e90c26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ config, pkgs, lib, ... }:

let
  public-inbox = config.services.public-inbox.package;

  public-inbox-src = pkgs.stdenv.mkDerivation {
    name = "public-inbox-${public-inbox.version}-qyliss.tar.gz";

    inherit (public-inbox) src patches;

    doBuild = false;

    installPhase = ''
      cd $NIX_BUILD_TOP
      mv $sourceRoot public-inbox-${public-inbox.version}-qyliss
      tar cf $out public-inbox-${public-inbox.version}-qyliss
    '';
  };

  hash = with lib;
    # Safe because we're just using the hash as a file name, and don't
    # need the file name itself to have a dependency on the src.
    builtins.unsafeDiscardStringContext
      (head (splitString "-"
        (last (splitString "/" public-inbox-src.outPath))));

  tarballName = "public-inbox-${public-inbox.version}-qyliss-${hash}.tar.gz";
in

{
  services.public-inbox.enable = true;
  services.public-inbox.path = with pkgs; [ spamassassin ];
  services.public-inbox.mda.args = [ "--no-precheck" ];
  services.public-inbox.mda.spamCheck = "spamc";
  services.public-inbox.nntp.extraGroups = [ "tls" ];
  services.public-inbox.wwwListing = "match=domain";

  services.public-inbox.config.publicinbox.css =
    [ "href=https://spectrum-os.org/lists/archives/public-inbox.css" ];

  services.public-inbox.config.publicinbox.sourceinfo =
    let
      url = "https://ftp.qyliss.net/public-inbox/${tarballName}";
    in (pkgs.writeText "public-inbox-source-info.html" ''
      <a href="${url}" download>${url}</a>
    '').outPath;

  ftp.files."public-inbox/${tarballName}" = public-inbox-src;

  services.spamassassin.enable = true;
  environment.etc."mail/spamassassin/public-inbox.pre".source =
    "${public-inbox.sa_config}/root/etc/spamassassin/public-inbox.pre";

  networking.firewall.allowedTCPPorts = [ 119 563 ];
}