1{ lib, python, buildPythonPackage, fetchFromGitHub, libmilter, bsddb3, pydns, iana-etc, libredirect }:
2
3buildPythonPackage rec {
4 pname = "pymilter";
5 version = "1.0.5";
6
7 src = fetchFromGitHub {
8 owner = "sdgathman";
9 repo = pname;
10 rev = "${pname}-${version}";
11 hash = "sha256-gZUWEDVZfDRiOOdG3lpiQldHxm/93l8qYVOHOEpHhzQ=";
12 };
13
14 buildInputs = [ libmilter ];
15 propagatedBuildInputs = [ bsddb3 pydns ];
16
17 preBuild = ''
18 sed -i 's/import thread/import _thread as thread/' Milter/greylist.py
19 '';
20
21 # requires /etc/resolv.conf
22 # testpolicy: requires makemap (#100419)
23 # using exec -a makemap smtpctl results in "unknown group smtpq"
24 preCheck = ''
25 echo "nameserver 127.0.0.1" > resolv.conf
26 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
27 export LD_PRELOAD=${libredirect}/lib/libredirect.so
28 sed -i '/testpolicy/d' test.py
29 rm testpolicy.py
30 '';
31
32 pythonImportsCheck = [ "Milter" ];
33
34 meta = with lib; {
35 homepage = "http://bmsi.com/python/milter.html";
36 description = "Python bindings for libmilter api";
37 maintainers = with maintainers; [ yorickvp ];
38 license = licenses.gpl2;
39 };
40}