summaryrefslogtreecommitdiffstats
path: root/nixos/tests/stalwart/stalwart-config.nix
blob: 399b527ea1d4b27d57e0a33eba8279b734678966 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{ lib, ... }:

let
  certs = import ../common/acme/server/snakeoil-certs.nix;
  domain = certs.domain;
in
{
  security.pki.certificateFiles = [ certs.ca.cert ];

  services.stalwart = {
    enable = true;

    stateVersion = lib.trivial.release; # Only for the test; please don't do in production

    settings = {
      server.hostname = domain;

      certificate."snakeoil" = {
        cert = "%{file:${certs.${domain}.cert}}%";
        private-key = "%{file:${certs.${domain}.key}}%";
      };

      server.tls = {
        certificate = "snakeoil";
        enable = true;
        implicit = false;
      };

      server.listener = {
        "smtp-submission" = {
          bind = [ "[::]:587" ];
          protocol = "smtp";
        };

        "imap" = {
          bind = [ "[::]:143" ];
          protocol = "imap";
        };

        "http" = {
          bind = [ "[::]:80" ];
          protocol = "http";
        };
      };

      session.auth.mechanisms = "[plain]";
      session.auth.directory = "'in-memory'";
      storage.directory = "in-memory";

      storage.data = "rocksdb";
      storage.fts = "rocksdb";
      storage.blob = "rocksdb";
      storage.lookup = "rocksdb";

      session.rcpt.directory = "'in-memory'";
      queue.strategy.route = "'local'";

      store."rocksdb" = {
        type = "rocksdb";
        path = "/var/lib/stalwart/data";
        compression = "lz4";
      };

      directory."in-memory" = {
        type = "memory";
        principals = [
          {
            class = "individual";
            name = "alice";
            secret = "foobar";
            email = [ "alice@${domain}" ];
          }
          {
            class = "individual";
            name = "bob";
            secret = "foobar";
            email = [ "bob@${domain}" ];
          }
        ];
      };
    };
  };

}