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