nixpkgs/pkgs/servers/mail/spamassassin/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
2.6 KiB
Nix
Raw Normal View History

2023-06-25 14:32:01 +00:00
{ lib, fetchurl, perlPackages, makeBinaryWrapper, gnupg, re2c, gcc, gnumake, libxcrypt, openssl, coreutils, poppler_utils, tesseract, iana-etc }:
2012-07-07 22:32:30 +00:00
perlPackages.buildPerlPackage rec {
pname = "SpamAssassin";
version = "4.0.0";
2012-07-07 22:32:30 +00:00
src = fetchurl {
url = "mirror://apache/spamassassin/source/Mail-${pname}-${version}.tar.bz2";
hash = "sha256-5aoXBQowvHK6qGr9xgSMrepNHsLsxh14dxegWbgxnog=";
2012-07-07 22:32:30 +00:00
};
2023-06-25 13:37:18 +00:00
patches = [
./satest-no-clean-path.patch
./sa_compile-use-perl5lib.patch
];
2023-06-25 14:32:01 +00:00
nativeBuildInputs = [ makeBinaryWrapper ];
buildInputs = (with perlPackages; [
HTMLParser NetCIDRLite NetDNS NetAddrIP DBFile HTTPDate MailDKIM LWP
spamassassin: support for fetching rules over HTTPS sa-update.service starts by making an HTTP GET request to http://spamassassin.apache.org/updates/MIRRORED.BY, which now redirects to HTTPS. Since we didn't have the appropriate library available to handle HTTPS, rule updates would fail: Jan 03 12:35:03 atuin systemd[1]: Starting sa-update.service... Jan 03 12:35:10 atuin sa-update-start[1250]: Update available for channel updates.spamassassin.org: 1895535 -> 1896618 Jan 03 12:35:10 atuin sa-update-start[1250]: http: (lwp) hotpatching IO::Socket::INET by module IO::Socket::IP Jan 03 12:35:11 atuin sa-update-start[1250]: http: (lwp) GET http://spamassassin.apache.org/updates/MIRRORED.BY, 501 Protocol scheme 'https' is not supported (LWP::Protocol::https not installed) Jan 03 12:35:11 atuin sa-update-start[1250]: error: unable to refresh mirrors file for channel updates.spamassassin.org, using old file Jan 03 12:35:11 atuin sa-update-start[1250]: error: no mirror data available for channel updates.spamassassin.org Jan 03 12:35:11 atuin sa-update-start[1250]: channel 'updates.spamassassin.org': MIRRORED.BY file contents were missing, channel failed Jan 03 12:35:11 atuin sa-update-start[1250]: Update failed, exiting with code 4 Jan 03 12:35:11 atuin systemd[1]: sa-update.service: Main process exited, code=exited, status=4/NOPERMISSION Jan 03 12:35:11 atuin systemd[1]: sa-update.service: Failed with result 'exit-code'. Jan 03 12:35:11 atuin systemd[1]: Failed to start sa-update.service.
2022-01-03 13:14:37 +00:00
LWPProtocolHttps IOSocketSSL DBI EncodeDetect IPCountry NetIdent
Razor2ClientAgent MailSPF NetDNSResolverProgrammable Socket6
ArchiveZip EmailAddressXS NetLibIDN2 MaxMindDBReader GeoIP MailDMARC
MaxMindDBReaderXS
]) ++ [
openssl
];
2012-07-07 22:32:30 +00:00
2023-06-25 14:32:01 +00:00
makeFlags = [ "PERL_BIN=${perlPackages.perl}/bin/perl" "ENABLE_SSL=yes" ];
2012-07-07 22:32:30 +00:00
makeMakerFlags = [ "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin" ];
2023-06-25 13:37:18 +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
'';
2012-07-07 22:32:30 +00:00
postInstall = ''
mkdir -p $out/share/spamassassin
mv "rules/"* $out/share/spamassassin/
for n in "$out/bin/"*; do
2023-06-25 14:32:01 +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 ]}
done
'';
2012-07-07 22:32:30 +00:00
meta = {
homepage = "https://spamassassin.apache.org/";
2012-07-07 22:32:30 +00:00
description = "Open-Source Spam Filter";
2021-01-15 07:07:56 +00:00
license = lib.licenses.asl20;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ qknight qyliss ];
2012-07-07 22:32:30 +00:00
};
}