summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2022-11-21 20:06:20 +0100
committerGitHub <noreply@github.com>2022-11-21 20:06:20 +0100
commit16bc8a29d67f6c4ba66660e91f69164400ee6ee1 (patch)
tree6103cde4426c754002ac20a6221f8f8a9d09c36a /pkgs/development
parent5f34f1ffadd9660fc8cb8dc19e958f54683a84c5 (diff)
parent3d8ffea12c2932cc355971a68c7bdaf15f6d7e7a (diff)
Merge pull request #195197 from yorickvP/upd-pypolicy
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/libraries/libmilter/default.nix8
-rw-r--r--pkgs/development/python-modules/pymilter/default.nix40
2 files changed, 46 insertions, 2 deletions
diff --git a/pkgs/development/libraries/libmilter/default.nix b/pkgs/development/libraries/libmilter/default.nix
index 9287b0a0dea78..38788b3c964ba 100644
--- a/pkgs/development/libraries/libmilter/default.nix
+++ b/pkgs/development/libraries/libmilter/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchurl, m4 }:
+{ lib, stdenv, fetchurl, m4, fixDarwinDylibNames }:
 
 stdenv.mkDerivation rec {
   pname = "libmilter";
@@ -34,7 +34,11 @@ stdenv.mkDerivation rec {
 
   patches = [ ./install.patch ./sharedlib.patch ./glibc-2.30.patch ./darwin.patch ];
 
-  nativeBuildInputs = [ m4 ];
+  nativeBuildInputs = [ m4 ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
+
+  postInstall = lib.optionalString stdenv.isDarwin ''
+    fixDarwinDylibNames $out/lib/libmilter.dylib.1
+  '';
 
   meta = with lib; {
     description = "Sendmail Milter mail filtering API library";
diff --git a/pkgs/development/python-modules/pymilter/default.nix b/pkgs/development/python-modules/pymilter/default.nix
new file mode 100644
index 0000000000000..0724161bf4236
--- /dev/null
+++ b/pkgs/development/python-modules/pymilter/default.nix
@@ -0,0 +1,40 @@
+{ lib, python, buildPythonPackage, fetchFromGitHub, libmilter, bsddb3, pydns, iana-etc, libredirect }:
+
+buildPythonPackage rec {
+  pname = "pymilter";
+  version = "1.0.5";
+
+  src = fetchFromGitHub {
+    owner = "sdgathman";
+    repo = pname;
+    rev = "${pname}-${version}";
+    hash = "sha256-gZUWEDVZfDRiOOdG3lpiQldHxm/93l8qYVOHOEpHhzQ=";
+  };
+
+  buildInputs = [ libmilter ];
+  propagatedBuildInputs = [ bsddb3 pydns ];
+
+  preBuild = ''
+    sed -i 's/import thread/import _thread as thread/' Milter/greylist.py
+  '';
+
+  # requires /etc/resolv.conf
+  # testpolicy: requires makemap (#100419)
+  #   using exec -a makemap smtpctl results in "unknown group smtpq"
+  preCheck = ''
+    echo "nameserver 127.0.0.1" > resolv.conf
+    export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
+    export LD_PRELOAD=${libredirect}/lib/libredirect.so
+    sed -i '/testpolicy/d' test.py
+    rm testpolicy.py
+  '';
+
+  pythonImportsCheck = [ "Milter" ];
+
+  meta = with lib; {
+    homepage = "http://bmsi.com/python/milter.html";
+    description = "Python bindings for libmilter api";
+    maintainers = with maintainers; [ yorickvp ];
+    license = licenses.gpl2;
+  };
+}