1 { lib, stdenv, unbound, openssl, expat, libevent, swig, pythonPackages }:
4 inherit (pythonPackages) python;
6 stdenv.mkDerivation rec {
8 inherit (unbound) version src;
9 patches = unbound.patches or null;
11 nativeBuildInputs = [ swig ];
13 buildInputs = [ openssl expat libevent python ];
16 substituteInPlace Makefile.in \
17 --replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \
18 --replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la"
21 preConfigure = "export PYTHON_VERSION=${python.pythonVersion}";
24 "--with-ssl=${openssl.dev}"
25 "--with-libexpat=${expat.dev}"
26 "--with-libevent=${libevent.dev}"
27 "--localstatedir=/var"
29 "--sbindir=\${out}/bin"
38 mkdir -p $out/${python.sitePackages} $out/etc/${pname}
39 cp .libs/_unbound.so .libs/libunbound.so* $out/${python.sitePackages}
40 substituteInPlace _unbound.la \
41 --replace "-L.libs $PWD/libunbound.la" "-L$out/${python.sitePackages}"
45 "configfile=\${out}/etc/unbound/unbound.conf"
50 # All we want is the Unbound Python module
52 # Generate the built in root anchor and root key and store these in a logical place
53 # to be used by tools depending only on the Python module
54 $out/bin/unbound-anchor -l | head -1 > $out/etc/${pname}/root.anchor
55 $out/bin/unbound-anchor -l | tail --lines=+2 - > $out/etc/${pname}/root.key
56 # We don't need anything else
57 rm -r $out/bin $out/share $out/include $out/etc/unbound
59 # patchelf is only available on Linux and no patching is needed on darwin
60 + lib.optionalString stdenv.isLinux ''
61 patchelf --replace-needed libunbound.so.8 $out/${python.sitePackages}/libunbound.so.8 $out/${python.sitePackages}/_unbound.so
65 description = "Python library for Unbound, the validating, recursive, and caching DNS resolver";
66 license = licenses.bsd3;
67 homepage = "https://www.unbound.net";
68 maintainers = with maintainers; [ leenaars ];
69 platforms = platforms.unix;