1 { lib, stdenv, fetchurl, pkg-config, gnutls, liburcu, lmdb, libcap_ng, libidn2, libunistring
2 , systemd, nettle, libedit, zlib, libiconv, libintl, libmaxminddb, libbpf, nghttp2, libmnl
3 , ngtcp2-gnutls, xdp-tools
5 , nixosTests, knot-resolver, knot-dns, runCommandLocal
8 stdenv.mkDerivation rec {
13 url = "https://secure.nic.cz/files/knot-dns/knot-${version}.tar.xz";
14 sha256 = "498de8338489a625673797f7ecc921fa4490c826afbfa42fa66922b525089e6a";
17 outputs = [ "bin" "out" "dev" ];
20 "--with-configdir=/etc/knot"
21 "--with-rundir=/run/knot"
22 "--with-storage=/var/lib/knot"
26 # Don't try to create directories like /var/lib/knot at build time.
27 # They are later created from NixOS itself.
28 ./dont-create-run-time-dirs.patch
32 nativeBuildInputs = [ pkg-config autoreconfHook ];
34 gnutls liburcu libidn2 libunistring
37 nghttp2 # DoH support in kdig
38 ngtcp2-gnutls # DoQ support in kdig (and elsewhere but not much use there yet)
39 libmaxminddb # optional for geoip module (it's tiny)
40 # without sphinx &al. for developer documentation
41 # TODO: add dnstap support?
42 ] ++ lib.optionals stdenv.isLinux [
44 xdp-tools libbpf libmnl # XDP support (it's Linux kernel API)
45 ] ++ lib.optional stdenv.isDarwin zlib; # perhaps due to gnutls
47 enableParallelBuilding = true;
49 CFLAGS = [ "-O2" "-DNDEBUG" ];
52 checkFlags = [ "V=1" ]; # verbose output in case some test fails
53 doInstallCheck = true;
60 inherit knot-resolver;
61 } // lib.optionalAttrs stdenv.isLinux {
62 inherit (nixosTests) knot kea;
63 prometheus-exporter = nixosTests.prometheus-exporters.knot;
64 # Some dependencies are very version-sensitive, so the might get dropped
65 # or embedded after some update, even if the nixPackagers didn't intend to.
66 # For non-linux I don't know a good replacement for `ldd`.
67 deps = runCommandLocal "knot-deps-test"
68 { nativeBuildInputs = [ (lib.getBin stdenv.cc.libc) ]; }
70 for libname in libngtcp2 libxdp libbpf; do
71 echo "Checking for $libname:"
72 ldd '${knot-dns.bin}/bin/knotd' | grep -F "$libname"
80 description = "Authoritative-only DNS server from .cz domain registry";
81 homepage = "https://knot-dns.cz";
82 license = licenses.gpl3Plus;
83 platforms = platforms.unix;
84 maintainers = [ maintainers.vcunat ];
85 mainProgram = "knotd";