1 { lib, fetchurl, perlPackages, makeBinaryWrapper, gnupg, re2c, gcc, gnumake, libxcrypt, openssl, coreutils, poppler_utils, tesseract, iana-etc }:
3 perlPackages.buildPerlPackage rec {
4 pname = "SpamAssassin";
9 url = "mirror://apache/spamassassin/source/Mail-${pname}-${version}.tar.bz2";
10 hash = "sha256-l3XtdVnoPsPmwD7bK+j/x/FcxAX7E+hcFI6wvxkXIag=";
12 defaultRulesSrc = fetchurl {
13 url = "mirror://apache/spamassassin/source/Mail-${pname}-rules-${version}.${rulesRev}.tgz";
14 hash = "sha256-OB6t/H5RPl9zU4m3gXPeWvRx89Bv5quPEpY0pmRLS/Q=";
18 ./satest-no-clean-path.patch
19 ./sa_compile-use-perl5lib.patch
22 nativeBuildInputs = [ makeBinaryWrapper ];
23 buildInputs = (with perlPackages; [
24 HTMLParser NetCIDRLite NetDNS NetAddrIP DBFile HTTPDate MailDKIM LWP
25 LWPProtocolHttps IOSocketSSL DBI EncodeDetect IPCountry NetIdent
26 Razor2ClientAgent MailSPF NetDNSResolverProgrammable Socket6
27 ArchiveZip EmailAddressXS NetLibIDN2 MaxMindDBReader GeoIP MailDMARC
33 makeFlags = [ "PERL_BIN=${perlPackages.perl}/bin/perl" "ENABLE_SSL=yes" ];
35 makeMakerFlags = [ "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin" ];
37 checkInputs = (with perlPackages; [
40 coreutils # date, t/basic_meta.t
41 poppler_utils # pdftotext, t/extracttext.t
42 tesseract # tesseract, t/extracttext.t
43 iana-etc # t/dnsbl_subtests.t (/etc/protocols used by Net::DNS::Nameserver)
47 substituteInPlace t/spamc_x_e.t \
48 --replace "/bin/echo" "${coreutils}/bin/echo"
49 export C_INCLUDE_PATH='${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}'
50 export HARNESS_OPTIONS="j''${NIX_BUILD_CORES}"
52 export HOME=$NIX_BUILD_TOP/home
54 mkdir t/log # pre-create to avoid race conditions
56 # https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8068
57 checkFlagsArray+=(TEST_FILES='$(shell find t -name *.t -not -name spamd_ssl_accept_fail.t)')
61 mkdir -p $out/share/spamassassin
62 mv "rules/"* $out/share/spamassassin/
64 tar -xzf ${defaultRulesSrc} -C $out/share/spamassassin/
65 local moduleversion="$(${perlPackages.perl}/bin/perl -I lib -e 'use Mail::SpamAssassin; print $Mail::SpamAssassin::VERSION')"
66 sed -i -e "s/@@VERSION@@/$moduleversion/" $out/share/spamassassin/*.cf
68 for n in "$out/bin/"*; do
69 # Skip if this isn't a perl script
70 if ! head -n1 "$n" | grep -q bin/perl; then
73 echo "Wrapping $n for taint mode"
74 orig="$out/bin/.$(basename "$n")-wrapped"
76 # We don't inherit argv0 so that $^X works properly in e.g. sa-compile
77 makeWrapper "${perlPackages.perl}/bin/perl" "$n" \
78 --add-flags "-T $perlFlags $orig" \
79 --prefix PATH : ${lib.makeBinPath [ gnupg re2c gcc gnumake ]} \
80 --prefix C_INCLUDE_PATH : ${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}
85 homepage = "https://spamassassin.apache.org/";
86 description = "Open-Source Spam Filter";
87 license = lib.licenses.asl20;
88 platforms = lib.platforms.unix;
89 maintainers = with lib.maintainers; [ qknight qyliss ];