2019-05-19 14:05:54 +02:00
|
|
|
{ stdenv, fetchurl
|
|
|
|
# native deps.
|
|
|
|
, runCommand, pkgconfig, meson, ninja, makeWrapper
|
|
|
|
# build+runtime deps.
|
|
|
|
, knot-dns, luajitPackages, libuv, gnutls, lmdb, systemd, dns-root-data
|
|
|
|
# test-only deps.
|
|
|
|
, cmocka, which, cacert
|
2017-09-22 11:27:59 +02:00
|
|
|
, extraFeatures ? false /* catch-all if defaults aren't enough */
|
2017-01-25 15:20:18 +01:00
|
|
|
}:
|
2018-02-01 17:15:28 +01:00
|
|
|
let # un-indented, over the whole file
|
2017-01-25 15:20:18 +01:00
|
|
|
|
2018-02-01 17:15:28 +01:00
|
|
|
result = if extraFeatures then wrapped-full else unwrapped;
|
|
|
|
|
2019-05-19 14:05:54 +02:00
|
|
|
inherit (stdenv.lib) optional optionals concatStringsSep;
|
|
|
|
lua = luajitPackages;
|
|
|
|
|
|
|
|
# FIXME: remove these usages once resolving
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/63108#issuecomment-508670438
|
|
|
|
exportLuaPathsFor = luaPkgs: ''
|
|
|
|
export LUA_PATH='${ concatStringsSep ";" (map lua.getLuaPath luaPkgs)}'
|
|
|
|
export LUA_CPATH='${concatStringsSep ";" (map lua.getLuaCPath luaPkgs)}'
|
|
|
|
'';
|
2018-02-01 17:15:28 +01:00
|
|
|
|
|
|
|
unwrapped = stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "knot-resolver";
|
2019-10-07 14:45:54 +02:00
|
|
|
version = "4.2.2";
|
2017-01-25 15:20:18 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-08-15 14:41:18 +02:00
|
|
|
url = "https://secure.nic.cz/files/knot-resolver/${pname}-${version}.tar.xz";
|
2019-10-07 14:45:54 +02:00
|
|
|
sha256 = "03b68dff16429aed7a5b0cea7189276c8056e8ecd567b678c2595d48d9a51458";
|
2017-01-25 15:20:18 +01:00
|
|
|
};
|
|
|
|
|
2019-08-09 16:07:12 +02:00
|
|
|
# https://gitlab.labs.nic.cz/knot/knot-resolver/issues/496
|
|
|
|
postPatch = "sed '/prefill.test.lua/d' -i modules/meson.build";
|
|
|
|
|
2017-01-25 15:20:18 +01:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2019-05-19 14:05:54 +02:00
|
|
|
preConfigure = ''
|
|
|
|
patchShebangs scripts/
|
|
|
|
''
|
|
|
|
+ stdenv.lib.optionalString doInstallCheck (exportLuaPathsFor [ lua.cqueues lua.basexx ]);
|
2017-01-25 15:20:18 +01:00
|
|
|
|
2019-05-19 14:05:54 +02:00
|
|
|
nativeBuildInputs = [ pkgconfig meson ninja ];
|
2017-01-25 22:41:07 +01:00
|
|
|
|
2017-09-22 11:27:59 +02:00
|
|
|
# http://knot-resolver.readthedocs.io/en/latest/build.html#requirements
|
2019-05-19 14:05:54 +02:00
|
|
|
buildInputs = [ knot-dns lua.lua libuv gnutls lmdb ]
|
|
|
|
++ optional stdenv.isLinux systemd # passing sockets, sd_notify
|
2018-02-01 17:15:28 +01:00
|
|
|
## optional dependencies; TODO: libedit, dnstap
|
|
|
|
;
|
2017-01-25 15:20:18 +01:00
|
|
|
|
2019-05-19 14:05:54 +02:00
|
|
|
mesonFlags = [
|
|
|
|
"-Dkeyfile_default=${dns-root-data}/root.ds"
|
|
|
|
"-Droot_hints=${dns-root-data}/root.hints"
|
|
|
|
"-Dinstall_kresd_conf=disabled" # not really useful; examples are inside share/doc/
|
|
|
|
"--default-library=static" # not used by anyone
|
|
|
|
]
|
2019-07-10 18:26:26 +02:00
|
|
|
++ optional doInstallCheck "-Dunit_tests=enabled"
|
|
|
|
++ optional (doInstallCheck && !stdenv.isDarwin) "-Dconfig_tests=enabled"
|
2019-05-19 14:05:54 +02:00
|
|
|
#"-Dextra_tests=enabled" # not suitable as in-distro tests; many deps, too.
|
2019-07-10 18:26:26 +02:00
|
|
|
;
|
2017-01-25 15:20:18 +01:00
|
|
|
|
2019-05-19 14:05:54 +02:00
|
|
|
postInstall = ''
|
|
|
|
rm "$out"/lib/libkres.a
|
2017-01-25 15:20:18 +01:00
|
|
|
'';
|
|
|
|
|
2019-07-10 16:52:57 +02:00
|
|
|
# aarch64: see https://github.com/wahern/cqueues/issues/223
|
|
|
|
doInstallCheck = with stdenv; hostPlatform == buildPlatform && !hostPlatform.isAarch64;
|
2019-05-19 14:05:54 +02:00
|
|
|
installCheckInputs = [ cmocka which cacert ];
|
|
|
|
installCheckPhase = ''
|
|
|
|
meson test --print-errorlogs
|
2018-02-01 17:15:28 +01:00
|
|
|
'';
|
2017-01-25 15:20:18 +01:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2017-01-25 18:41:52 +01:00
|
|
|
description = "Caching validating DNS resolver, from .cz domain registry";
|
2017-01-25 15:20:18 +01:00
|
|
|
homepage = https://knot-resolver.cz;
|
|
|
|
license = licenses.gpl3Plus;
|
2019-07-10 16:52:57 +02:00
|
|
|
platforms = platforms.unix;
|
2017-01-25 15:20:18 +01:00
|
|
|
maintainers = [ maintainers.vcunat /* upstream developer */ ];
|
|
|
|
};
|
2018-02-01 17:15:28 +01:00
|
|
|
};
|
|
|
|
|
2019-07-05 10:42:08 +02:00
|
|
|
# FIXME: revert this back after resolving
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/63108#issuecomment-508670438
|
|
|
|
wrapped-full =
|
|
|
|
with stdenv.lib;
|
|
|
|
with luajitPackages;
|
|
|
|
let
|
|
|
|
luaPkgs = [
|
2018-07-08 09:21:16 +02:00
|
|
|
luasec luasocket # trust anchor bootstrap, prefill module
|
2019-06-13 13:01:10 +02:00
|
|
|
luafilesystem # prefill module
|
2019-05-01 11:19:49 +02:00
|
|
|
http # for http module; brings lots of deps; some are useful elsewhere
|
2019-07-05 10:42:08 +02:00
|
|
|
cqueues fifo lpeg lpeg_patterns luaossl compat53 basexx binaryheap
|
2018-07-08 09:21:16 +02:00
|
|
|
];
|
2019-07-05 10:42:08 +02:00
|
|
|
in runCommand unwrapped.name
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2018-02-01 17:15:28 +01:00
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
|
|
|
}
|
2019-05-19 14:05:54 +02:00
|
|
|
(exportLuaPathsFor luaPkgs
|
|
|
|
+ ''
|
2019-05-01 11:19:49 +02:00
|
|
|
mkdir -p "$out"/{bin,share}
|
|
|
|
makeWrapper '${unwrapped}/bin/kresd' "$out"/bin/kresd \
|
2019-05-19 14:05:54 +02:00
|
|
|
--set LUA_PATH "$LUA_PATH" \
|
|
|
|
--set LUA_CPATH "$LUA_CPATH"
|
2019-07-05 10:42:08 +02:00
|
|
|
|
2018-02-01 17:15:28 +01:00
|
|
|
ln -sr '${unwrapped}/share/man' "$out"/share/
|
2019-05-01 11:19:49 +02:00
|
|
|
ln -sr "$out"/{bin,sbin}
|
2019-07-05 11:00:51 +02:00
|
|
|
|
|
|
|
echo "Checking that 'http' module loads, i.e. lua search paths work:"
|
|
|
|
echo "modules.load('http')" > test-http.lua
|
|
|
|
echo -e 'quit()' | env -i "$out"/bin/kresd -a 127.0.0.1#53535 -c test-http.lua
|
2019-05-19 14:05:54 +02:00
|
|
|
'');
|
2018-02-01 17:15:28 +01:00
|
|
|
|
|
|
|
in result
|