nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 cmake,
6 doctest,
7 fmt_11,
8 perl,
9 glib,
10 luajit,
11 openssl,
12 pcre,
13 pkg-config,
14 sqlite,
15 ragel,
16 fasttext,
17 icu,
18 vectorscan,
19 jemalloc,
20 blas,
21 lapack,
22 lua,
23 libsodium,
24 xxHash,
25 zstd,
26 libarchive,
27 # Enabling blas support breaks bayes filter training from dovecot in nixos-mailserver tests
28 # https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/issues/321
29 withBlas ? false,
30 withLuaJIT ? stdenv.hostPlatform.isx86_64,
31 nixosTests,
32}:
33
34stdenv.mkDerivation rec {
35 pname = "rspamd";
36 version = "3.12.1";
37
38 src = fetchFromGitHub {
39 owner = "rspamd";
40 repo = "rspamd";
41 rev = version;
42 hash = "sha256-bAkT0msUkgGkjAIlF7lnJbimBKW1NSn2zjkCj3ErJ1I=";
43 };
44
45 hardeningEnable = [ "pie" ];
46
47 nativeBuildInputs = [
48 cmake
49 pkg-config
50 perl
51 ragel
52 ];
53
54 buildInputs = [
55 doctest
56 fmt_11
57 glib
58 openssl
59 pcre
60 sqlite
61 ragel
62 fasttext
63 icu
64 jemalloc
65 libsodium
66 xxHash
67 zstd
68 libarchive
69 vectorscan
70 ]
71 ++ lib.optionals withBlas [
72 blas
73 lapack
74 ]
75 ++ lib.optional withLuaJIT luajit
76 ++ lib.optional (!withLuaJIT) lua;
77
78 cmakeFlags = [
79 # pcre2 jit seems to cause crashes: https://github.com/NixOS/nixpkgs/pull/181908
80 "-DENABLE_PCRE2=OFF"
81 "-DDEBIAN_BUILD=ON"
82 "-DRUNDIR=/run/rspamd"
83 "-DDBDIR=/var/lib/rspamd"
84 "-DLOGDIR=/var/log/rspamd"
85 "-DLOCAL_CONFDIR=/etc/rspamd"
86 "-DENABLE_BLAS=${if withBlas then "ON" else "OFF"}"
87 "-DENABLE_FASTTEXT=ON"
88 "-DENABLE_JEMALLOC=ON"
89 "-DSYSTEM_DOCTEST=ON"
90 "-DSYSTEM_FMT=ON"
91 "-DSYSTEM_XXHASH=ON"
92 "-DSYSTEM_ZSTD=ON"
93 "-DENABLE_HYPERSCAN=ON"
94 ]
95 ++ lib.optional (!withLuaJIT) "-DENABLE_LUAJIT=OFF";
96
97 passthru.tests.rspamd = nixosTests.rspamd;
98
99 meta = with lib; {
100 homepage = "https://rspamd.com";
101 license = licenses.asl20;
102 description = "Advanced spam filtering system";
103 maintainers = with maintainers; [
104 avnik
105 fpletz
106 globin
107 lewo
108 ];
109 platforms = with platforms; linux;
110 };
111}