2023-07-15 17:15:38 +00:00
|
|
|
{ lib, fetchurl, perlPackages, makeBinaryWrapper, gnupg, re2c, gcc, gnumake, libxcrypt, openssl, coreutils, poppler_utils, tesseract, iana-etc }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
perlPackages.buildPerlPackage rec {
|
|
|
|
pname = "SpamAssassin";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "4.0.0";
|
2023-10-09 19:29:22 +00:00
|
|
|
rulesRev = "r1905950";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://apache/spamassassin/source/Mail-${pname}-${version}.tar.bz2";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-5aoXBQowvHK6qGr9xgSMrepNHsLsxh14dxegWbgxnog=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
defaultRulesSrc = fetchurl {
|
|
|
|
url = "mirror://apache/spamassassin/source/Mail-${pname}-rules-${version}.${rulesRev}.tgz";
|
|
|
|
hash = "sha256-rk/7uRfrx/76ckD8W7UVHdpmP45AWRYa18m0Lu0brG0=";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
patches = [
|
|
|
|
./satest-no-clean-path.patch
|
|
|
|
./sa_compile-use-perl5lib.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeBinaryWrapper ];
|
2021-03-09 03:18:52 +00:00
|
|
|
buildInputs = (with perlPackages; [
|
2020-04-24 23:36:52 +00:00
|
|
|
HTMLParser NetCIDRLite NetDNS NetAddrIP DBFile HTTPDate MailDKIM LWP
|
2022-01-13 20:06:32 +00:00
|
|
|
LWPProtocolHttps IOSocketSSL DBI EncodeDetect IPCountry NetIdent
|
|
|
|
Razor2ClientAgent MailSPF NetDNSResolverProgrammable Socket6
|
2023-07-15 17:15:38 +00:00
|
|
|
ArchiveZip EmailAddressXS NetLibIDN2 MaxMindDBReader GeoIP MailDMARC
|
|
|
|
MaxMindDBReaderXS
|
|
|
|
]) ++ [
|
|
|
|
openssl
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
makeFlags = [ "PERL_BIN=${perlPackages.perl}/bin/perl" "ENABLE_SSL=yes" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makeMakerFlags = [ "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin" ];
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
checkInputs = (with perlPackages; [
|
|
|
|
TextDiff # t/strip2.t
|
|
|
|
]) ++ [
|
|
|
|
coreutils # date, t/basic_meta.t
|
|
|
|
poppler_utils # pdftotext, t/extracttext.t
|
|
|
|
tesseract # tesseract, t/extracttext.t
|
|
|
|
iana-etc # t/dnsbl_subtests.t (/etc/protocols used by Net::DNS::Nameserver)
|
|
|
|
re2c gcc gnumake
|
|
|
|
];
|
|
|
|
preCheck = ''
|
|
|
|
substituteInPlace t/spamc_x_e.t \
|
|
|
|
--replace "/bin/echo" "${coreutils}/bin/echo"
|
|
|
|
export C_INCLUDE_PATH='${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}'
|
|
|
|
export HARNESS_OPTIONS="j''${NIX_BUILD_CORES}"
|
|
|
|
|
|
|
|
export HOME=$NIX_BUILD_TOP/home
|
|
|
|
mkdir -p $HOME
|
|
|
|
mkdir t/log # pre-create to avoid race conditions
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/spamassassin
|
|
|
|
mv "rules/"* $out/share/spamassassin/
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
tar -xzf ${defaultRulesSrc} -C $out/share/spamassassin/
|
|
|
|
local moduleversion="$(${perlPackages.perl}/bin/perl -I lib -e 'use Mail::SpamAssassin; print $Mail::SpamAssassin::VERSION')"
|
|
|
|
sed -i -e "s/@@VERSION@@/$moduleversion/" $out/share/spamassassin/*.cf
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
for n in "$out/bin/"*; do
|
2023-07-15 17:15:38 +00:00
|
|
|
# Skip if this isn't a perl script
|
|
|
|
if ! head -n1 "$n" | grep -q bin/perl; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Wrapping $n for taint mode"
|
|
|
|
orig="$out/bin/.$(basename "$n")-wrapped"
|
|
|
|
mv "$n" "$orig"
|
|
|
|
# We don't inherit argv0 so that $^X works properly in e.g. sa-compile
|
|
|
|
makeWrapper "${perlPackages.perl}/bin/perl" "$n" \
|
|
|
|
--add-flags "-T $perlFlags $orig" \
|
|
|
|
--prefix PATH : ${lib.makeBinPath [ gnupg re2c gcc gnumake ]} \
|
|
|
|
--prefix C_INCLUDE_PATH : ${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2022-01-03 16:56:52 +00:00
|
|
|
homepage = "https://spamassassin.apache.org/";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Open-Source Spam Filter";
|
2021-01-15 22:18:51 +00:00
|
|
|
license = lib.licenses.asl20;
|
|
|
|
platforms = lib.platforms.unix;
|
2021-10-17 02:12:59 +00:00
|
|
|
maintainers = with lib.maintainers; [ qknight qyliss ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|