18 perlPackages.buildPerlPackage rec {
19 pname = "SpamAssassin";
21 rulesRev = "r1916528";
24 url = "mirror://apache/spamassassin/source/Mail-${pname}-${version}.tar.bz2";
25 hash = "sha256-l3XtdVnoPsPmwD7bK+j/x/FcxAX7E+hcFI6wvxkXIag=";
27 defaultRulesSrc = fetchurl {
28 url = "mirror://apache/spamassassin/source/Mail-${pname}-rules-${version}.${rulesRev}.tgz";
29 hash = "sha256-OB6t/H5RPl9zU4m3gXPeWvRx89Bv5quPEpY0pmRLS/Q=";
33 ./satest-no-clean-path.patch
34 ./sa_compile-use-perl5lib.patch
37 nativeBuildInputs = [ makeBinaryWrapper ];
56 NetDNSResolverProgrammable
71 "PERL_BIN=${perlPackages.perl}/bin/perl"
75 makeMakerFlags = [ "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin" ];
82 coreutils # date, t/basic_meta.t
83 poppler_utils # pdftotext, t/extracttext.t
84 tesseract # tesseract, t/extracttext.t
85 iana-etc # t/dnsbl_subtests.t (/etc/protocols used by Net::DNS::Nameserver)
91 substituteInPlace t/spamc_x_e.t \
92 --replace "/bin/echo" "${coreutils}/bin/echo"
93 export C_INCLUDE_PATH='${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}'
94 export HARNESS_OPTIONS="j''${NIX_BUILD_CORES}"
96 export HOME=$NIX_BUILD_TOP/home
98 mkdir t/log # pre-create to avoid race conditions
100 # https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8068
101 checkFlagsArray+=(TEST_FILES='$(shell find t -name *.t -not -name spamd_ssl_accept_fail.t)')
105 mkdir -p $out/share/spamassassin
106 mv "rules/"* $out/share/spamassassin/
108 tar -xzf ${defaultRulesSrc} -C $out/share/spamassassin/
109 local moduleversion="$(${perlPackages.perl}/bin/perl -I lib -e 'use Mail::SpamAssassin; print $Mail::SpamAssassin::VERSION')"
110 sed -i -e "s/@@VERSION@@/$moduleversion/" $out/share/spamassassin/*.cf
112 for n in "$out/bin/"*; do
113 # Skip if this isn't a perl script
114 if ! head -n1 "$n" | grep -q bin/perl; then
117 echo "Wrapping $n for taint mode"
118 orig="$out/bin/.$(basename "$n")-wrapped"
120 # We don't inherit argv0 so that $^X works properly in e.g. sa-compile
121 makeWrapper "${perlPackages.perl}/bin/perl" "$n" \
122 --add-flags "-T $perlFlags $orig" \
131 --prefix C_INCLUDE_PATH : ${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}
136 homepage = "https://spamassassin.apache.org/";
137 description = "Open-Source Spam Filter";
138 license = lib.licenses.asl20;
139 platforms = lib.platforms.unix;
140 maintainers = with lib.maintainers; [