2022-01-05 14:28:59 +00:00
|
|
|
{ lib, stdenv, fetchurl
|
2019-05-19 13:05:54 +01:00
|
|
|
# native deps.
|
2021-01-19 06:50:56 +00:00
|
|
|
, runCommand, pkg-config, meson, ninja, makeWrapper
|
2019-05-19 13:05:54 +01:00
|
|
|
# build+runtime deps.
|
2020-11-18 07:38:23 +00:00
|
|
|
, knot-dns, luajitPackages, libuv, gnutls, lmdb
|
|
|
|
, systemd, libcap_ng, dns-root-data, nghttp2 # optionals, in principle
|
2019-05-19 13:05:54 +01:00
|
|
|
# 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;
|
|
|
|
|
2021-01-15 07:07:56 +00:00
|
|
|
inherit (lib) optional optionals optionalString;
|
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";
|
2022-08-16 14:10:08 +01:00
|
|
|
version = "5.5.2";
|
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";
|
2022-08-16 14:10:08 +01:00
|
|
|
sha256 = "3f78aa69c3f28edc42b5900b9788fba39498d8bffda7fb9c772bb470865780cb";
|
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 @@
|
2020-12-09 10:07:28 +00:00
|
|
|
-systemd_work_dir = prefix / get_option('localstatedir') / 'lib' / 'knot-resolver'
|
|
|
|
-systemd_cache_dir = prefix / get_option('localstatedir') / 'cache' / 'knot-resolver'
|
2020-02-05 18:27:16 +00:00
|
|
|
+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
|
2020-11-12 17:57:50 +00:00
|
|
|
''
|
|
|
|
# some tests have issues with network sandboxing, apparently
|
|
|
|
+ optionalString doInstallCheck ''
|
|
|
|
echo 'os.exit(77)' > daemon/lua/trust_anchors.test/bootstrap.test.lua
|
2021-07-29 15:39:35 +01:00
|
|
|
sed -E '/^[[:blank:]]*test_(dstaddr|headers),?$/d' -i \
|
2021-02-25 13:47:35 +00:00
|
|
|
tests/config/doh2.test.lua modules/http/http_doh.test.lua
|
2020-02-05 18:27:16 +00:00
|
|
|
'';
|
|
|
|
|
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
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config 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 ]
|
2022-04-29 10:12:29 +01:00
|
|
|
++ optionals stdenv.isLinux [ /*lib*/systemd libcap_ng ]
|
2020-11-18 07:38:23 +00:00
|
|
|
++ [ nghttp2 ]
|
|
|
|
## optional dependencies; TODO: dnstap
|
2018-02-01 16:15:28 +00:00
|
|
|
;
|
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
|
2020-11-17 19:05:51 +00:00
|
|
|
'' + optionalString stdenv.targetPlatform.isLinux ''
|
2020-11-11 14:33:22 +00:00
|
|
|
rm -r "$out"/lib/sysusers.d/ # ATM more likely to harm than help
|
2017-01-25 14:20:18 +00:00
|
|
|
'';
|
|
|
|
|
2022-04-29 10:31:51 +01:00
|
|
|
doInstallCheck = with stdenv; hostPlatform == buildPlatform;
|
2020-11-12 17:57:50 +00:00
|
|
|
installCheckInputs = [ cmocka which cacert lua.cqueues lua.basexx lua.http ];
|
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
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with 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
|