2019-05-19 13:05:54 +01: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 10:27:59 +01:00
|
|
|
, extraFeatures ? false /* catch-all if defaults aren't enough */
|
2017-01-25 14:20:18 +00:00
|
|
|
}:
|
2018-02-01 16:15:28 +00:00
|
|
|
let # un-indented, over the whole file
|
2017-01-25 14:20:18 +00:00
|
|
|
|
2018-02-01 16:15:28 +00:00
|
|
|
result = if extraFeatures then wrapped-full else unwrapped;
|
|
|
|
|
2019-05-19 13:05:54 +01: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 16:15:28 +00:00
|
|
|
|
|
|
|
unwrapped = stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "knot-resolver";
|
2019-12-04 15:19:33 +00:00
|
|
|
version = "4.3.0";
|
2017-01-25 14:20:18 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-08-15 13:41:18 +01:00
|
|
|
url = "https://secure.nic.cz/files/knot-resolver/${pname}-${version}.tar.xz";
|
2019-12-04 15:19:33 +00:00
|
|
|
sha256 = "0ca0f171ae2b2d76830967a5150eb0fa496b48b2a48f41b2be65d3743aaece25";
|
2017-01-25 14:20:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2019-05-19 13:05:54 +01:00
|
|
|
preConfigure = ''
|
|
|
|
patchShebangs scripts/
|
|
|
|
''
|
|
|
|
+ stdenv.lib.optionalString doInstallCheck (exportLuaPathsFor [ lua.cqueues lua.basexx ]);
|
2017-01-25 14:20:18 +00:00
|
|
|
|
2019-05-19 13:05:54 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig meson ninja ];
|
2017-01-25 21:41:07 +00:00
|
|
|
|
2017-09-22 10:27:59 +01:00
|
|
|
# http://knot-resolver.readthedocs.io/en/latest/build.html#requirements
|
2019-05-19 13:05:54 +01:00
|
|
|
buildInputs = [ knot-dns lua.lua libuv gnutls lmdb ]
|
|
|
|
++ optional stdenv.isLinux systemd # passing sockets, sd_notify
|
2018-02-01 16:15:28 +00:00
|
|
|
## optional dependencies; TODO: libedit, dnstap
|
|
|
|
;
|
2017-01-25 14:20:18 +00:00
|
|
|
|
2019-05-19 13:05:54 +01: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 17:26:26 +01:00
|
|
|
++ optional doInstallCheck "-Dunit_tests=enabled"
|
|
|
|
++ optional (doInstallCheck && !stdenv.isDarwin) "-Dconfig_tests=enabled"
|
2019-05-19 13:05:54 +01:00
|
|
|
#"-Dextra_tests=enabled" # not suitable as in-distro tests; many deps, too.
|
2019-07-10 17:26:26 +01:00
|
|
|
;
|
2017-01-25 14:20:18 +00:00
|
|
|
|
2019-05-19 13:05:54 +01:00
|
|
|
postInstall = ''
|
|
|
|
rm "$out"/lib/libkres.a
|
2017-01-25 14:20:18 +00:00
|
|
|
'';
|
|
|
|
|
2020-01-27 14:38:32 +00:00
|
|
|
doInstallCheck = with stdenv; hostPlatform == buildPlatform;
|
2019-05-19 13:05:54 +01:00
|
|
|
installCheckInputs = [ cmocka which cacert ];
|
|
|
|
installCheckPhase = ''
|
|
|
|
meson test --print-errorlogs
|
2018-02-01 16:15:28 +00:00
|
|
|
'';
|
2017-01-25 14:20:18 +00:00
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2017-01-25 17:41:52 +00:00
|
|
|
description = "Caching validating DNS resolver, from .cz domain registry";
|
2017-01-25 14:20:18 +00:00
|
|
|
homepage = https://knot-resolver.cz;
|
|
|
|
license = licenses.gpl3Plus;
|
2019-07-10 15:52:57 +01:00
|
|
|
platforms = platforms.unix;
|
2017-01-25 14:20:18 +00:00
|
|
|
maintainers = [ maintainers.vcunat /* upstream developer */ ];
|
|
|
|
};
|
2018-02-01 16:15:28 +00:00
|
|
|
};
|
|
|
|
|
2019-07-05 09:42:08 +01: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 08:21:16 +01:00
|
|
|
luasec luasocket # trust anchor bootstrap, prefill module
|
2019-06-13 12:01:10 +01:00
|
|
|
luafilesystem # prefill module
|
2019-05-01 10:19:49 +01:00
|
|
|
http # for http module; brings lots of deps; some are useful elsewhere
|
2019-07-05 09:42:08 +01:00
|
|
|
cqueues fifo lpeg lpeg_patterns luaossl compat53 basexx binaryheap
|
2018-07-08 08:21:16 +01:00
|
|
|
];
|
2019-07-05 09:42:08 +01:00
|
|
|
in runCommand unwrapped.name
|
|
|
|
{
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2018-02-01 16:15:28 +00:00
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
|
|
|
}
|
2019-05-19 13:05:54 +01:00
|
|
|
(exportLuaPathsFor luaPkgs
|
|
|
|
+ ''
|
2019-05-01 10:19:49 +01:00
|
|
|
mkdir -p "$out"/{bin,share}
|
|
|
|
makeWrapper '${unwrapped}/bin/kresd' "$out"/bin/kresd \
|
2019-05-19 13:05:54 +01:00
|
|
|
--set LUA_PATH "$LUA_PATH" \
|
|
|
|
--set LUA_CPATH "$LUA_CPATH"
|
2019-07-05 09:42:08 +01:00
|
|
|
|
2018-02-01 16:15:28 +00:00
|
|
|
ln -sr '${unwrapped}/share/man' "$out"/share/
|
2019-05-01 10:19:49 +01:00
|
|
|
ln -sr "$out"/{bin,sbin}
|
2019-07-05 10:00:51 +01: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 13:05:54 +01:00
|
|
|
'');
|
2018-02-01 16:15:28 +00:00
|
|
|
|
|
|
|
in result
|