2020-02-05 18:27:16 +00:00
|
|
|
{ stdenv, fetchurl, fetchpatch
|
2019-05-19 13:05:54 +01:00
|
|
|
# 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;
|
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
inherit (stdenv.lib) optional optionals;
|
2019-05-19 13:05:54 +01:00
|
|
|
lua = luajitPackages;
|
|
|
|
|
2018-02-01 16:15:28 +00:00
|
|
|
unwrapped = stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "knot-resolver";
|
2020-09-09 07:10:16 +01:00
|
|
|
version = "5.1.3";
|
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";
|
2020-09-09 07:10:16 +01:00
|
|
|
sha256 = "20cd829027e39a9f7d993894e3640e886825b492d9ac1a744ac5616cc101458b";
|
2017-01-25 14:20:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
# Path fixups for the NixOS service.
|
|
|
|
postPatch = ''
|
|
|
|
patch meson.build <<EOF
|
|
|
|
@@ -50,2 +50,2 @@
|
|
|
|
-systemd_work_dir = join_paths(prefix, get_option('localstatedir'), 'lib', 'knot-resolver')
|
|
|
|
-systemd_cache_dir = join_paths(prefix, get_option('localstatedir'), 'cache', 'knot-resolver')
|
|
|
|
+systemd_work_dir = '/var/lib/knot-resolver'
|
|
|
|
+systemd_cache_dir = '/var/cache/knot-resolver'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# ExecStart can't be overwritten in overrides.
|
|
|
|
# We need that to use wrapped executable and correct config file.
|
|
|
|
sed '/^ExecStart=/d' -i systemd/kresd@.service.in
|
|
|
|
'';
|
|
|
|
|
2019-05-19 13:05:54 +01:00
|
|
|
preConfigure = ''
|
|
|
|
patchShebangs scripts/
|
2020-02-05 18:27:16 +00:00
|
|
|
'';
|
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"
|
2020-02-05 18:27:16 +00:00
|
|
|
++ optional stdenv.isLinux "-Dsystemd_files=enabled" # used by NixOS service
|
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
|
2020-02-05 18:27:16 +00:00
|
|
|
rm "$out"/lib/knot-resolver/upgrade-4-to-5.lua # not meaningful on NixOS
|
2017-01-25 14:20:18 +00:00
|
|
|
'';
|
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
doInstallCheck = with stdenv; hostPlatform == buildPlatform;
|
|
|
|
installCheckInputs = [ cmocka which cacert lua.cqueues lua.basexx ];
|
2019-05-19 13:05:54 +01:00
|
|
|
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";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://knot-resolver.cz";
|
2017-01-25 14:20:18 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
wrapped-full = runCommand unwrapped.name
|
2020-01-27 14:14:42 +00:00
|
|
|
{
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2020-02-05 18:27:16 +00:00
|
|
|
buildInputs = with luajitPackages; [
|
|
|
|
# For http module, prefill module, trust anchor bootstrap.
|
|
|
|
# It brings lots of deps; some are useful elsewhere (e.g. cqueues).
|
|
|
|
http
|
|
|
|
# psl isn't in nixpkgs yet, but policy.slice_randomize_psl() seems not important.
|
|
|
|
];
|
2018-02-01 16:15:28 +00:00
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
|
|
|
}
|
2020-02-05 18:27:16 +00:00
|
|
|
''
|
|
|
|
mkdir -p "$out"/bin
|
2019-05-01 10:19:49 +01:00
|
|
|
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
|
|
|
|
2020-02-05 18:27:16 +00:00
|
|
|
ln -sr '${unwrapped}/share' "$out"/
|
|
|
|
ln -sr '${unwrapped}/lib' "$out"/ # useful in NixOS service
|
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
|
2020-02-05 18:27:16 +00:00
|
|
|
'';
|
2018-02-01 16:15:28 +00:00
|
|
|
|
|
|
|
in result
|