2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchurl, openssl, expat, libevent, swig, pythonPackages }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
inherit (pythonPackages) python;
|
2021-08-06 21:57:35 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "pyunbound";
|
2021-08-06 21:57:35 +00:00
|
|
|
version = "1.13.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-08-06 21:57:35 +00:00
|
|
|
url = "https://nlnetlabs.nl/downloads/unbound/unbound-${version}.tar.gz";
|
|
|
|
sha256 = "sha256-hQTZe4/FvYlzRcldEW4O4N34yP+ZWQqytL0TJ4yfULg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-08-06 21:57:35 +00:00
|
|
|
nativeBuildInputs = [ swig ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-06 21:57:35 +00:00
|
|
|
buildInputs = [ openssl expat libevent python ];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile.in \
|
|
|
|
--replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \
|
|
|
|
--replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preConfigure = "export PYTHON_VERSION=${python.pythonVersion}";
|
|
|
|
|
|
|
|
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"
|
2021-08-06 21:57:35 +00:00
|
|
|
"DESTDIR=$out"
|
|
|
|
"PREFIX="
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $out/${python.sitePackages} $out/etc/${pname}
|
|
|
|
cp .libs/_unbound.so .libs/libunbound.so* $out/${python.sitePackages}
|
|
|
|
substituteInPlace _unbound.la \
|
2021-08-06 21:57:35 +00:00
|
|
|
--replace "-L.libs $PWD/libunbound.la" "-L$out/${python.sitePackages}"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-06 21:57:35 +00:00
|
|
|
installFlags = [
|
|
|
|
"configfile=\${out}/etc/unbound/unbound.conf"
|
|
|
|
"pyunbound-install"
|
|
|
|
"lib"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# 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
|
2021-08-06 21:57:35 +00:00
|
|
|
rm -r $out/bin $out/share $out/include $out/etc/unbound
|
|
|
|
''
|
|
|
|
# patchelf is only available on Linux and no patching is needed on darwin
|
|
|
|
+ lib.optionalString stdenv.isLinux ''
|
|
|
|
patchelf --replace-needed libunbound.so.8 $out/${python.sitePackages}/libunbound.so.8 $out/${python.sitePackages}/_unbound.so
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Python library for Unbound, the validating, recursive, and caching DNS resolver";
|
|
|
|
license = licenses.bsd3;
|
2021-08-06 21:57:35 +00:00
|
|
|
homepage = "https://www.unbound.net";
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ leenaars ];
|
2021-08-06 21:57:35 +00:00
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|