nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 configFile ? "/etc/nsd/nsd.conf",
23}:
24
25stdenv.mkDerivation rec {
26 pname = "nsd";
27 version = "4.12.0";
28
29 src = fetchurl {
30 url = "https://www.nlnetlabs.nl/downloads/${pname}/${pname}-${version}.tar.gz";
31 sha256 = "sha256-+ezCz3m6UFgPLfYpGO/EQAhMW/EQV9tEwZqpZDzUteg=";
32 };
33
34 prePatch = ''
35 substituteInPlace nsd-control-setup.sh.in --replace openssl ${openssl}/bin/openssl
36 '';
37
38 nativeBuildInputs = lib.optionals withSystemd [
39 pkg-config
40 ];
41
42 buildInputs = [
43 libevent
44 openssl
45 ]
46 ++ lib.optionals withSystemd [
47 systemdMinimal
48 ];
49
50 enableParallelBuilding = true;
51
52 configureFlags =
53 let
54 edf = c: o: if c then [ "--enable-${o}" ] else [ "--disable-${o}" ];
55 in
56 edf bind8Stats "bind8-stats"
57 ++ edf checking "checking"
58 ++ edf ipv6 "ipv6"
59 ++ edf mmap "mmap"
60 ++ edf minimalResponses "minimal-responses"
61 ++ edf nsec3 "nsec3"
62 ++ edf ratelimit "ratelimit"
63 ++ edf recvmmsg "recvmmsg"
64 ++ edf rootServer "root-server"
65 ++ edf rrtypes "draft-rrtypes"
66 ++ edf zoneStats "zone-stats"
67 ++ edf withSystemd "systemd"
68 ++ [
69 "--with-ssl=${openssl.dev}"
70 "--with-libevent=${libevent.dev}"
71 "--with-nsd_conf_file=${configFile}"
72 "--with-configdir=etc/nsd"
73 ];
74
75 patchPhase = ''
76 sed 's@$(INSTALL_DATA) nsd.conf.sample $(DESTDIR)$(nsdconfigfile).sample@@g' -i Makefile.in
77 '';
78
79 passthru.tests = {
80 inherit (nixosTests) nsd;
81 };
82
83 meta = {
84 homepage = "https://www.nlnetlabs.nl";
85 description = "Authoritative only, high performance, simple and open source name server";
86 license = lib.licenses.bsd3;
87 platforms = lib.platforms.unix;
88 };
89}