summary refs log tree commit diff
path: root/pkgs/tools/networking/unbound
diff options
context:
space:
mode:
authorMichiel Leenaars <ml.software@leenaa.rs>2016-07-23 00:25:36 +0200
committerMichiel Leenaars <ml.software@leenaa.rs>2016-08-01 09:51:33 +0200
commitc8f2d8dae0f3a7511c708e4896502654361f4a67 (patch)
treea6cb8c59817ff14b57effb79a841e5f9749b7ba7 /pkgs/tools/networking/unbound
parent55904aa5c402bc5bdc9d34d22a51e7ef0af8a601 (diff)
downloadnixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.tar
nixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.tar.gz
nixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.tar.bz2
nixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.tar.lz
nixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.tar.xz
nixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.tar.zst
nixpkgs-c8f2d8dae0f3a7511c708e4896502654361f4a67.zip
py-unbound: init at 1.5.9
Diffstat (limited to 'pkgs/tools/networking/unbound')
-rw-r--r--pkgs/tools/networking/unbound/python.nix63
1 files changed, 63 insertions, 0 deletions
diff --git a/pkgs/tools/networking/unbound/python.nix b/pkgs/tools/networking/unbound/python.nix
new file mode 100644
index 00000000000..b2f43740a67
--- /dev/null
+++ b/pkgs/tools/networking/unbound/python.nix
@@ -0,0 +1,63 @@
+{ stdenv, fetchurl, openssl, expat, libevent, swig, python, pythonPackages }:
+
+stdenv.mkDerivation rec {
+  pname = "pyunbound";
+  name = "${pname}-${version}";
+  version = "1.5.9";
+
+  src = fetchurl {
+    url = "http://unbound.net/downloads/unbound-${version}.tar.gz";
+    sha256 = "01328cfac99ab5b8c47115151896a244979e442e284eb962c0ea84b7782b6990";
+  };
+
+  buildInputs = [ openssl expat libevent swig python ];
+
+  patchPhase = ''substituteInPlace Makefile.in \
+    --replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \
+    --replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la"
+    '';
+
+  preConfigure = "export PYTHON_VERSION=${python.majorVersion}";
+
+  configureFlags = [
+    "--with-ssl=${openssl.dev}"
+    "--with-libexpat=${expat.dev}"
+    "--with-libevent=${libevent.dev}"
+    "--localstatedir=/var"
+    "--sysconfdir=/etc"
+    "--sbindir=\${out}/bin"
+    "--enable-pie"
+    "--enable-relro-now"
+    "--with-pyunbound"
+    "DESTDIR=$out PREFIX="
+  ];
+
+  preInstall = ''
+    mkdir -p $out/${python.sitePackages} $out/etc/${pname}
+    cp .libs/_unbound.so .libs/libunbound.so* $out/${python.sitePackages}
+    substituteInPlace _unbound.la \
+      --replace "-L.libs $PWD/libunbound.la" "-L$out/${python.sitePackages}" \
+      --replace "libdir=\'$PWD/${python.sitePackages}\'" "libdir=\'$out/${python.sitePackages}\'"
+    '';
+
+  installFlags = [ "configfile=\${out}/etc/unbound/unbound.conf pyunbound-install lib" ];
+
+  # All we want is the Unbound Python module
+  postInstall = ''
+    # Generate the built in root anchor and root key and store these in a logical place 
+    # to be used by tools depending only on the Python module
+    $out/bin/unbound-anchor -l | head -1 > $out/etc/${pname}/root.anchor
+    $out/bin/unbound-anchor -l | tail --lines=+2 - > $out/etc/${pname}/root.key
+    # We don't need anything else
+    rm -fR $out/bin $out/share $out/include $out/etc/unbound
+    patchelf --replace-needed libunbound.so.2 $out/${python.sitePackages}/libunbound.so.2 $out/${python.sitePackages}/_unbound.so 
+    '';
+
+  meta = with stdenv.lib; {
+    description = "Python library for Unbound, the validating, recursive, and caching DNS resolver";
+    license = licenses.bsd3;
+    homepage = http://www.unbound.net;
+    maintainers = with maintainers; [ leenaars ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}