about summary refs log tree commit diff stats
path: root/pkgs/by-name/st/stalwart-mail-patched/package.nix
blob: 9058f2ce35f9c6e8ff472055452dcd6aac4c5710 (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
{
  stalwart-mail,
  callPackage,
  nixLib,
}: let
  spamfilter = callPackage ./spam-filter.nix {};
in
  stalwart-mail.overrideAttrs (final: prev: {
    pname = "stalwart-mail-patched";

    passthru = nixLib.warnMerge (prev.passthru or {}) {
      inherit spamfilter;
    } "stalwart-mail passthru";

    # The NixOS build tests should check if this works.
    # And this shaves of around 50% of the build time.
    doCheck = false;

    # We are already overriding it, so shaving of some unused features is okay.
    buildNoDefaultFeatures = true;
    buildFeatures = [
      # "sqlite"
      # "postgres"
      # "mysql"
      "rocks"
      # "elastic"
      # "s3"
      "redis"
      "tls-native-roots"
    ];

    cargoPatches =
      (prev.cargoPatches or [])
      ++ [
        # `stalwart-mail` uses their bundled store, which makes it impossible to use our
        # own CA certificate (e.g., for tests). Thus use a native version.
        ./patches/use-platform-ca-roots.patch
      ];

    # Check that the enterprise feature is really disabled.
    postCheck =
      (prev.postCheck or "")
      +
      # bash
      ''
        if grep "enterprise" ./target/*/release/stalwart-mail.d; then
          echo "ERROR: Proprietary 'enterprise' feature active."
          exit 1
        fi
      '';

    meta.mainProgram = prev.meta.mainProgram or "stalwart-mail";
  })