at 16.09-beta 65 lines 2.4 kB view raw
1{ stdenv, fetchurl, openssl, expat, libevent, swig, pythonPackages }: 2 3let 4 inherit (pythonPackages) python; 5in stdenv.mkDerivation rec { 6 pname = "pyunbound"; 7 name = "${pname}-${version}"; 8 version = "1.5.9"; 9 10 src = fetchurl { 11 url = "http://unbound.net/downloads/unbound-${version}.tar.gz"; 12 sha256 = "01328cfac99ab5b8c47115151896a244979e442e284eb962c0ea84b7782b6990"; 13 }; 14 15 buildInputs = [ openssl expat libevent swig python ]; 16 17 patchPhase = ''substituteInPlace Makefile.in \ 18 --replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \ 19 --replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la" 20 ''; 21 22 preConfigure = "export PYTHON_VERSION=${python.majorVersion}"; 23 24 configureFlags = [ 25 "--with-ssl=${openssl.dev}" 26 "--with-libexpat=${expat.dev}" 27 "--with-libevent=${libevent.dev}" 28 "--localstatedir=/var" 29 "--sysconfdir=/etc" 30 "--sbindir=\${out}/bin" 31 "--enable-pie" 32 "--enable-relro-now" 33 "--with-pyunbound" 34 "DESTDIR=$out PREFIX=" 35 ]; 36 37 preInstall = '' 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}" \ 42 --replace "libdir=\'$PWD/${python.sitePackages}\'" "libdir=\'$out/${python.sitePackages}\'" 43 ''; 44 45 installFlags = [ "configfile=\${out}/etc/unbound/unbound.conf pyunbound-install lib" ]; 46 47 # All we want is the Unbound Python module 48 postInstall = '' 49 # Generate the built in root anchor and root key and store these in a logical place 50 # to be used by tools depending only on the Python module 51 $out/bin/unbound-anchor -l | head -1 > $out/etc/${pname}/root.anchor 52 $out/bin/unbound-anchor -l | tail --lines=+2 - > $out/etc/${pname}/root.key 53 # We don't need anything else 54 rm -fR $out/bin $out/share $out/include $out/etc/unbound 55 patchelf --replace-needed libunbound.so.2 $out/${python.sitePackages}/libunbound.so.2 $out/${python.sitePackages}/_unbound.so 56 ''; 57 58 meta = with stdenv.lib; { 59 description = "Python library for Unbound, the validating, recursive, and caching DNS resolver"; 60 license = licenses.bsd3; 61 homepage = http://www.unbound.net; 62 maintainers = with maintainers; [ leenaars ]; 63 platforms = stdenv.lib.platforms.unix; 64 }; 65}