15 , enablePython ? false
26 stdenv.mkDerivation rec {
31 url = "https://downloads.isc.org/isc/bind9/${version}/${pname}-${version}.tar.xz";
32 hash = "sha256-58zpoWX3thnu/Egy8KjcFrAF0p44kK7WAIxQbqKGpec=";
35 outputs = [ "out" "lib" "dev" "man" "dnsutils" "host" ];
38 ./dont-keep-configure-flags.patch
41 nativeBuildInputs = [ perl pkg-config ];
42 buildInputs = [ libidn2 libtool libxml2 openssl libuv nghttp2 jemalloc ]
43 ++ lib.optional stdenv.isLinux libcap
44 ++ lib.optional enableGSSAPI libkrb5
45 ++ lib.optional enablePython (python3.withPackages (ps: with ps; [ ply ]))
46 ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.CoreServices ];
48 depsBuildBuild = [ buildPackages.stdenv.cc ];
51 "--localstatedir=/var"
54 ] ++ lib.optional enableGSSAPI "--with-gssapi=${libkrb5.dev}/bin/krb5-config"
55 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "BUILD_CC=$(CC_FOR_BUILD)";
58 moveToOutput bin/bind9-config $dev
60 moveToOutput bin/host $host
62 moveToOutput bin/dig $dnsutils
63 moveToOutput bin/delv $dnsutils
64 moveToOutput bin/nslookup $dnsutils
65 moveToOutput bin/nsupdate $dnsutils
67 for f in "$lib/lib/"*.la "$dev/bin/"bind*-config; do
68 sed -i "$f" -e 's|-L${openssl.dev}|-L${lib.getLib openssl}|g'
71 cat <<EOF >$out/etc/rndc.conf
72 include "/etc/bind/rndc.key";
74 default-key "rndc-key";
75 default-server 127.0.0.1;
81 enableParallelBuilding = true;
84 # TODO: investigate failures; see this and linked discussions:
85 # https://github.com/NixOS/nixpkgs/pull/192962
87 doCheck = with stdenv.hostPlatform; !isStatic && !(isAarch64 && isLinux)
88 # https://gitlab.isc.org/isc-projects/bind9/-/issues/4269
94 ] ++ lib.optionals (!stdenv.hostPlatform.isMusl) [
97 preCheck = lib.optionalString stdenv.hostPlatform.isMusl ''
98 # musl doesn't respect TZDIR, skip timezone-related tests
99 sed -i '/^ISC_TEST_ENTRY(isc_time_formatISO8601L/d' tests/isc/time_test.c
100 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
101 # Test timeouts on Darwin
102 sed -i '/^ISC_TEST_ENTRY(tcpdns_recv_one/d' tests/isc/netmgr_test.c
107 inherit (nixosTests) bind;
108 prometheus-exporter = nixosTests.prometheus-exporters.bind;
109 kubernetes-dns-single-node = nixosTests.kubernetes.dns-single-node;
110 kubernetes-dns-multi-node = nixosTests.kubernetes.dns-multi-node;
113 updateScript = gitUpdater {
114 # No nicer place to find latest stable release.
115 url = "https://gitlab.isc.org/isc-projects/bind9.git";
117 # Avoid unstable 9.19 releases.
123 homepage = "https://www.isc.org/bind/";
124 description = "Domain name server";
125 license = licenses.mpl20;
126 changelog = "https://downloads.isc.org/isc/bind9/cur/${lib.versions.majorMinor version}/CHANGES";
127 maintainers = with maintainers; [ globin ];
128 platforms = platforms.unix;
130 outputsToInstall = [ "out" "dnsutils" "host" ];