rio: 0.0.36 -> 0.0.37
[NixPkgs.git] / pkgs / tools / networking / unbound / python.nix
blob94f2374d904d00362acc8a0de810dfd6fefebae2
1 { lib, stdenv, unbound, openssl, expat, libevent, swig, pythonPackages }:
3 let
4   inherit (pythonPackages) python;
5 in
6 stdenv.mkDerivation rec {
7   pname = "pyunbound";
8   inherit (unbound) version src;
9   patches = unbound.patches or null;
11   nativeBuildInputs = [ swig ];
13   buildInputs = [ openssl expat libevent python ];
15   postPatch = ''
16     substituteInPlace Makefile.in \
17       --replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \
18       --replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la"
19   '';
21   preConfigure = "export PYTHON_VERSION=${python.pythonVersion}";
23   configureFlags = [
24     "--with-ssl=${openssl.dev}"
25     "--with-libexpat=${expat.dev}"
26     "--with-libevent=${libevent.dev}"
27     "--localstatedir=/var"
28     "--sysconfdir=/etc"
29     "--sbindir=\${out}/bin"
30     "--enable-pie"
31     "--enable-relro-now"
32     "--with-pyunbound"
33     "DESTDIR=$out"
34     "PREFIX="
35   ];
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   '';
44   installFlags = [
45     "configfile=\${out}/etc/unbound/unbound.conf"
46     "pyunbound-install"
47     "lib"
48   ];
50   # All we want is the Unbound Python module
51   postInstall = ''
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
58   ''
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
62   '';
64   meta = with lib; {
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;
70   };