nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchurl,
5 removeReferencesTo,
6 perl,
7 pkg-config,
8 libcap,
9 libidn2,
10 libtool,
11 libxml2,
12 openssl,
13 liburcu,
14 libuv,
15 nghttp2,
16 jemalloc,
17 enablePython ? false,
18 python3,
19 enableGSSAPI ? true,
20 libkrb5,
21 buildPackages,
22 nixosTests,
23 cmocka,
24 tzdata,
25 gitUpdater,
26 fstrm,
27 protobufc,
28}:
29
30stdenv.mkDerivation (finalAttrs: {
31 pname = "bind";
32 version = "9.20.18";
33
34 src = fetchurl {
35 url = "https://downloads.isc.org/isc/bind9/${finalAttrs.version}/bind-${finalAttrs.version}.tar.xz";
36 hash = "sha256-38VGyZCsRRVSnNRcTdmVhisYrootDLKSCOiJal0yUzE=";
37 };
38
39 outputs = [
40 "out"
41 "lib"
42 "dev"
43 "man"
44 "dnsutils"
45 "host"
46 ];
47
48 patches = [
49 ./dont-keep-configure-flags.patch
50 ];
51
52 nativeBuildInputs = [
53 perl
54 pkg-config
55 protobufc
56 removeReferencesTo
57 ];
58 buildInputs = [
59 libidn2
60 libtool
61 libxml2
62 openssl
63 liburcu
64 libuv
65 nghttp2
66 jemalloc
67 fstrm
68 protobufc
69 ]
70 ++ lib.optional stdenv.hostPlatform.isLinux libcap
71 ++ lib.optional enableGSSAPI libkrb5
72 ++ lib.optional enablePython (python3.withPackages (ps: with ps; [ ply ]));
73
74 depsBuildBuild = [ buildPackages.stdenv.cc ];
75
76 configureFlags = [
77 "--localstatedir=/var"
78 "--without-lmdb"
79 "--enable-dnstap"
80 "--with-libidn2"
81 ]
82 ++ lib.optional enableGSSAPI "--with-gssapi=${libkrb5.dev}/bin/krb5-config"
83 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "BUILD_CC=$(CC_FOR_BUILD)";
84
85 postInstall = ''
86 moveToOutput bin/bind9-config $dev
87
88 moveToOutput bin/host $host
89
90 moveToOutput bin/dig $dnsutils
91 moveToOutput bin/delv $dnsutils
92 moveToOutput bin/nslookup $dnsutils
93 moveToOutput bin/nsupdate $dnsutils
94
95 for f in "$lib/lib/"*.la "$dev/bin/"bind*-config; do
96 sed -i "$f" -e 's|-L${openssl.dev}|-L${lib.getLib openssl}|g'
97 done
98
99 mkdir -p $out/etc
100 cat <<EOF >$out/etc/rndc.conf
101 include "/etc/bind/rndc.key";
102 options {
103 default-key "rndc-key";
104 default-server 127.0.0.1;
105 default-port 953;
106 };
107 EOF
108 '';
109
110 enableParallelBuilding = true;
111 strictDeps = true;
112
113 doCheck = false;
114 # TODO: investigate failures; see this and linked discussions:
115 # https://github.com/NixOS/nixpkgs/pull/192962
116 /*
117 doCheck = with stdenv.hostPlatform; !isStatic && !(isAarch64 && isLinux)
118 # https://gitlab.isc.org/isc-projects/bind9/-/issues/4269
119 && !is32bit;
120 */
121 checkTarget = "unit";
122 checkInputs = [
123 cmocka
124 ]
125 ++ lib.optionals (!stdenv.hostPlatform.isMusl) [
126 tzdata
127 ];
128 preCheck =
129 lib.optionalString stdenv.hostPlatform.isMusl ''
130 # musl doesn't respect TZDIR, skip timezone-related tests
131 sed -i '/^ISC_TEST_ENTRY(isc_time_formatISO8601L/d' tests/isc/time_test.c
132 ''
133 + lib.optionalString stdenv.hostPlatform.isDarwin ''
134 # Test timeouts on Darwin
135 sed -i '/^ISC_TEST_ENTRY(tcpdns_recv_one/d' tests/isc/netmgr_test.c
136 '';
137
138 postFixup = ''
139 remove-references-to -t "$out" "$dnsutils/bin/delv"
140 '';
141
142 passthru = {
143 tests = {
144 withCheck = finalAttrs.finalPackage.overrideAttrs { doCheck = true; };
145 inherit (nixosTests) bind;
146 prometheus-exporter = nixosTests.prometheus-exporters.bind;
147 }
148 // lib.optionalAttrs (stdenv.hostPlatform.system == "x86_64-linux") {
149 kubernetes-dns-single-node = nixosTests.kubernetes.dns-single-node;
150 kubernetes-dns-multi-node = nixosTests.kubernetes.dns-multi-node;
151 };
152
153 updateScript = gitUpdater {
154 # No nicer place to find latest stable release.
155 url = "https://gitlab.isc.org/isc-projects/bind9.git";
156 rev-prefix = "v";
157 # Avoid unstable 9.19 releases.
158 odd-unstable = true;
159 };
160 };
161
162 meta = {
163 homepage = "https://www.isc.org/bind/";
164 description = "Domain name server";
165 license = lib.licenses.mpl20;
166 changelog = "https://downloads.isc.org/isc/bind9/cur/${lib.versions.majorMinor finalAttrs.version}/doc/arm/html/notes.html#notes-for-bind-${
167 lib.replaceStrings [ "." ] [ "-" ] finalAttrs.version
168 }";
169 maintainers = [ ];
170 platforms = lib.platforms.unix;
171
172 outputsToInstall = [
173 "out"
174 "dnsutils"
175 "host"
176 ];
177 };
178})