1{
2 lib,
3 stdenv,
4 fetchurl,
5 libevent,
6 openssl,
7 pkg-config,
8 systemdMinimal,
9 nixosTests,
10 bind8Stats ? false,
11 checking ? false,
12 ipv6 ? true,
13 mmap ? false,
14 minimalResponses ? true,
15 nsec3 ? true,
16 ratelimit ? false,
17 recvmmsg ? false,
18 rootServer ? false,
19 rrtypes ? false,
20 zoneStats ? false,
21 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdMinimal,
22
23 configFile ? "/etc/nsd/nsd.conf",
24}:
25
26stdenv.mkDerivation rec {
27 pname = "nsd";
28 version = "4.11.1";
29
30 src = fetchurl {
31 url = "https://www.nlnetlabs.nl/downloads/${pname}/${pname}-${version}.tar.gz";
32 sha256 = "sha256-aW5QBSAI3k+nqx2BjVt362MkfuovBXURTJWS/5GIphQ=";
33 };
34
35 prePatch = ''
36 substituteInPlace nsd-control-setup.sh.in --replace openssl ${openssl}/bin/openssl
37 '';
38
39 buildInputs = [
40 libevent
41 openssl
42 ]
43 ++ lib.optionals withSystemd [
44 systemdMinimal
45 pkg-config
46 ];
47
48 enableParallelBuilding = true;
49
50 configureFlags =
51 let
52 edf = c: o: if c then [ "--enable-${o}" ] else [ "--disable-${o}" ];
53 in
54 edf bind8Stats "bind8-stats"
55 ++ edf checking "checking"
56 ++ edf ipv6 "ipv6"
57 ++ edf mmap "mmap"
58 ++ edf minimalResponses "minimal-responses"
59 ++ edf nsec3 "nsec3"
60 ++ edf ratelimit "ratelimit"
61 ++ edf recvmmsg "recvmmsg"
62 ++ edf rootServer "root-server"
63 ++ edf rrtypes "draft-rrtypes"
64 ++ edf zoneStats "zone-stats"
65 ++ edf withSystemd "systemd"
66 ++ [
67 "--with-ssl=${openssl.dev}"
68 "--with-libevent=${libevent.dev}"
69 "--with-nsd_conf_file=${configFile}"
70 "--with-configdir=etc/nsd"
71 ];
72
73 patchPhase = ''
74 sed 's@$(INSTALL_DATA) nsd.conf.sample $(DESTDIR)$(nsdconfigfile).sample@@g' -i Makefile.in
75 '';
76
77 passthru.tests = {
78 inherit (nixosTests) nsd;
79 };
80
81 meta = with lib; {
82 homepage = "https://www.nlnetlabs.nl";
83 description = "Authoritative only, high performance, simple and open source name server";
84 license = licenses.bsd3;
85 platforms = platforms.unix;
86 maintainers = [ maintainers.hrdinka ];
87 };
88}