at master 2.4 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 unbound, 5 openssl, 6 expat, 7 libevent, 8 bison, 9 flex, 10 swig, 11 python, 12 stdenv, 13}: 14 15buildPythonPackage rec { 16 pname = "pyunbound"; 17 inherit (unbound) version src; 18 pyproject = false; # Built with configure script 19 20 patches = unbound.patches or null; 21 22 nativeBuildInputs = [ 23 bison 24 flex 25 swig 26 ]; 27 28 buildInputs = [ 29 openssl 30 expat 31 libevent 32 python 33 ]; 34 35 postPatch = '' 36 substituteInPlace Makefile.in \ 37 --replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \ 38 --replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la" 39 ''; 40 41 preConfigure = "export PYTHON_VERSION=${python.pythonVersion}"; 42 43 configureFlags = [ 44 "--with-ssl=${openssl.dev}" 45 "--with-libexpat=${expat.dev}" 46 "--with-libevent=${libevent.dev}" 47 "--localstatedir=/var" 48 "--sysconfdir=/etc" 49 "--sbindir=\${out}/bin" 50 "--enable-pie" 51 "--enable-relro-now" 52 "--with-pyunbound" 53 "DESTDIR=$out" 54 "PREFIX=" 55 ]; 56 57 preInstall = '' 58 mkdir -p $out/${python.sitePackages} $out/etc/${pname} 59 cp .libs/_unbound.so .libs/libunbound.so* $out/${python.sitePackages} 60 substituteInPlace _unbound.la \ 61 --replace "-L.libs $PWD/libunbound.la" "-L$out/${python.sitePackages}" 62 ''; 63 64 installFlags = [ 65 "configfile=\${out}/etc/unbound/unbound.conf" 66 "pyunbound-install" 67 "lib" 68 ]; 69 70 # All we want is the Unbound Python module 71 postInstall = '' 72 # Generate the built in root anchor and root key and store these in a logical place 73 # to be used by tools depending only on the Python module 74 $out/bin/unbound-anchor -l | head -1 > $out/etc/${pname}/root.anchor 75 $out/bin/unbound-anchor -l | tail --lines=+2 - > $out/etc/${pname}/root.key 76 # We don't need anything else 77 rm -r $out/bin $out/share $out/include $out/etc/unbound 78 '' 79 # patchelf is only available on Linux and no patching is needed on darwin 80 + lib.optionalString stdenv.hostPlatform.isLinux '' 81 patchelf --replace-needed libunbound.so.8 $out/${python.sitePackages}/libunbound.so.8 $out/${python.sitePackages}/_unbound.so 82 ''; 83 84 meta = with lib; { 85 description = "Python library for Unbound, the validating, recursive, and caching DNS resolver"; 86 license = licenses.bsd3; 87 homepage = "https://www.unbound.net"; 88 maintainers = with maintainers; [ leenaars ]; 89 platforms = platforms.unix; 90 }; 91}