2021-08-23 23:08:21 +02:00
|
|
|
{ lib, stdenv, unbound, openssl, expat, libevent, swig, pythonPackages }:
|
2016-07-23 00:25:36 +02:00
|
|
|
|
2016-08-01 10:19:48 +02:00
|
|
|
let
|
|
|
|
inherit (pythonPackages) python;
|
2021-08-06 09:17:08 +02:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2016-07-23 00:25:36 +02:00
|
|
|
pname = "pyunbound";
|
2021-08-23 23:08:21 +02:00
|
|
|
inherit (unbound) version src;
|
2016-07-23 00:25:36 +02:00
|
|
|
|
2021-08-05 23:32:19 +02:00
|
|
|
nativeBuildInputs = [ swig ];
|
2016-07-23 00:25:36 +02:00
|
|
|
|
2021-08-05 23:32:19 +02:00
|
|
|
buildInputs = [ openssl expat libevent python ];
|
|
|
|
|
2021-08-06 09:17:08 +02:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile.in \
|
|
|
|
--replace "\$(DESTDIR)\$(PYTHON_SITE_PKG)" "$out/${python.sitePackages}" \
|
|
|
|
--replace "\$(LIBTOOL) --mode=install cp _unbound.la" "cp _unbound.la"
|
2021-08-05 23:32:19 +02:00
|
|
|
'';
|
2016-07-23 00:25:36 +02:00
|
|
|
|
2019-01-03 10:05:50 +01:00
|
|
|
preConfigure = "export PYTHON_VERSION=${python.pythonVersion}";
|
2016-07-23 00:25:36 +02:00
|
|
|
|
|
|
|
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-05 23:32:19 +02:00
|
|
|
"DESTDIR=$out"
|
|
|
|
"PREFIX="
|
2016-07-23 00:25:36 +02: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-05 23:32:19 +02:00
|
|
|
--replace "-L.libs $PWD/libunbound.la" "-L$out/${python.sitePackages}"
|
2021-08-06 09:17:08 +02:00
|
|
|
'';
|
2016-07-23 00:25:36 +02:00
|
|
|
|
2021-08-05 23:32:19 +02:00
|
|
|
installFlags = [
|
|
|
|
"configfile=\${out}/etc/unbound/unbound.conf"
|
|
|
|
"pyunbound-install"
|
|
|
|
"lib"
|
|
|
|
];
|
2016-07-23 00:25:36 +02:00
|
|
|
|
|
|
|
# All we want is the Unbound Python module
|
|
|
|
postInstall = ''
|
2019-01-03 10:05:50 +01:00
|
|
|
# Generate the built in root anchor and root key and store these in a logical place
|
2016-07-23 00:25:36 +02:00
|
|
|
# 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 09:17:08 +02:00
|
|
|
rm -r $out/bin $out/share $out/include $out/etc/unbound
|
2021-08-06 00:03:58 +02:00
|
|
|
''
|
|
|
|
# patchelf is only available on Linux and no patching is needed on darwin
|
|
|
|
+ lib.optionalString stdenv.isLinux ''
|
2021-08-05 21:15:02 +02:00
|
|
|
patchelf --replace-needed libunbound.so.8 $out/${python.sitePackages}/libunbound.so.8 $out/${python.sitePackages}/_unbound.so
|
2021-08-05 23:32:19 +02:00
|
|
|
'';
|
2016-07-23 00:25:36 +02:00
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2016-07-23 00:25:36 +02:00
|
|
|
description = "Python library for Unbound, the validating, recursive, and caching DNS resolver";
|
|
|
|
license = licenses.bsd3;
|
2021-08-06 09:17:08 +02:00
|
|
|
homepage = "https://www.unbound.net";
|
2016-07-23 00:25:36 +02:00
|
|
|
maintainers = with maintainers; [ leenaars ];
|
2021-08-06 09:17:08 +02:00
|
|
|
platforms = platforms.unix;
|
2016-07-23 00:25:36 +02:00
|
|
|
};
|
|
|
|
}
|