nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at netboot-syslinux-multiplatform 198 lines 6.6 kB view raw
1{ lib 2, stdenv 3, fetchzip 4, fetchpatch 5, makeWrapper 6, nixosTests 7, pkg-config 8, file 9, linuxHeaders 10, openssl 11, pcre 12, perlPackages 13, python3 14, xz 15, zlib 16, catch2 17# recommended dependencies 18, withHwloc ? true 19, hwloc 20, withCurl ? true 21, curl 22, withCurses ? true 23, ncurses 24, withCap ? stdenv.isLinux 25, libcap 26, withUnwind ? stdenv.isLinux 27, libunwind 28# optional dependencies 29, withBrotli ? false 30, brotli 31, withCjose ? false 32, cjose 33, withGeoIP ? false 34, geoip 35, withHiredis ? false 36, hiredis 37, withImageMagick ? false 38, imagemagick 39, withJansson ? false 40, jansson 41, withKyotoCabinet ? false 42, kyotocabinet 43, withLuaJIT ? false 44, luajit 45, withMaxmindDB ? false 46, libmaxminddb 47# optional features 48, enableWCCP ? false 49}: 50 51stdenv.mkDerivation rec { 52 pname = "trafficserver"; 53 version = "9.1.4"; 54 55 src = fetchzip { 56 url = "mirror://apache/trafficserver/trafficserver-${version}.tar.bz2"; 57 sha256 = "sha256-+iq+z+1JE6JE6OLcUwRRAe2/EISqb6Ax6pNm8GcB7bc="; 58 }; 59 60 patches = [ 61 # Adds support for NixOS 62 # https://github.com/apache/trafficserver/pull/7697 63 (fetchpatch { 64 url = "https://github.com/apache/trafficserver/commit/19d3af481cf74c91fbf713fc9d2f8b138ed5fbaf.diff"; 65 sha256 = "0z1ikgpp00rzrrcqh97931586yn9wbksgai9xlkcjd5cg8gq0150"; 66 }) 67 ]; 68 69 # NOTE: The upstream README indicates that flex is needed for some features, 70 # but it actually seems to be unnecessary as of this commit[1]. The detection 71 # logic for bison and flex is still present in the build script[2], but no 72 # other code seems to depend on it. This situation is susceptible to change 73 # though, so it's a good idea to inspect the build scripts periodically. 74 # 75 # [1]: https://github.com/apache/trafficserver/pull/5617 76 # [2]: https://github.com/apache/trafficserver/blob/3fd2c60/configure.ac#L742-L788 77 nativeBuildInputs = [ makeWrapper pkg-config file python3 ] 78 ++ (with perlPackages; [ perl ExtUtilsMakeMaker ]) 79 ++ lib.optionals stdenv.isLinux [ linuxHeaders ]; 80 81 buildInputs = [ 82 openssl 83 pcre 84 perlPackages.perl 85 ] ++ lib.optional withBrotli brotli 86 ++ lib.optional withCap libcap 87 ++ lib.optional withCjose cjose 88 ++ lib.optional withCurl curl 89 ++ lib.optional withGeoIP geoip 90 ++ lib.optional withHiredis hiredis 91 ++ lib.optional withHwloc hwloc 92 ++ lib.optional withImageMagick imagemagick 93 ++ lib.optional withJansson jansson 94 ++ lib.optional withKyotoCabinet kyotocabinet 95 ++ lib.optional withCurses ncurses 96 ++ lib.optional withLuaJIT luajit 97 ++ lib.optional withUnwind libunwind 98 ++ lib.optional withMaxmindDB libmaxminddb; 99 100 outputs = [ "out" "man" ]; 101 102 postPatch = '' 103 patchShebangs \ 104 iocore/aio/test_AIO.sample \ 105 src/traffic_via/test_traffic_via \ 106 src/traffic_logstats/tests \ 107 tools/check-unused-dependencies 108 109 substituteInPlace configure --replace '/usr/bin/file' '${file}/bin/file' 110 '' + lib.optionalString stdenv.isLinux '' 111 substituteInPlace configure \ 112 --replace '/usr/include/linux' '${linuxHeaders}/include/linux' 113 '' + lib.optionalString stdenv.isDarwin '' 114 # 'xcrun leaks' probably requires non-free XCode 115 substituteInPlace iocore/net/test_certlookup.cc \ 116 --replace 'xcrun leaks' 'true' 117 ''; 118 119 configureFlags = [ 120 "--enable-layout=NixOS" 121 "--enable-experimental-plugins" 122 (lib.enableFeature enableWCCP "wccp") 123 124 (lib.withFeatureAs withHiredis "hiredis" hiredis) 125 ]; 126 127 installFlags = [ 128 "pkgsysconfdir=${placeholder "out"}/etc/trafficserver" 129 130 # replace runtime directories with an install-time placeholder directory 131 "pkgcachedir=${placeholder "out"}/.install-trafficserver" 132 "pkglocalstatedir=${placeholder "out"}/.install-trafficserver" 133 "pkglogdir=${placeholder "out"}/.install-trafficserver" 134 "pkgruntimedir=${placeholder "out"}/.install-trafficserver" 135 ]; 136 137 postInstall = '' 138 substituteInPlace rc/trafficserver.service --replace "syslog.target" "" 139 install -Dm644 rc/trafficserver.service $out/lib/systemd/system/trafficserver.service 140 141 wrapProgram $out/bin/tspush \ 142 --set PERL5LIB '${with perlPackages; makePerlPath [ URI ]}' \ 143 --prefix PATH : "${lib.makeBinPath [ file ]}" 144 145 find "$out" -name '*.la' -delete 146 147 # ensure no files actually exist in this directory 148 rmdir $out/.install-trafficserver 149 ''; 150 151 installCheckPhase = let 152 expected = '' 153 Via header is [uScMsEf p eC:t cCMp sF], Length is 22 154 Via Header Details: 155 Request headers received from client :simple request (not conditional) 156 Result of Traffic Server cache lookup for URL :miss (a cache "MISS") 157 Response information received from origin server :error in response 158 Result of document write-to-cache: :no cache write performed 159 Proxy operation result :unknown 160 Error codes (if any) :connection to server failed 161 Tunnel info :no tunneling 162 Cache Type :cache 163 Cache Lookup Result :cache miss (url not in cache) 164 Parent proxy connection status :no parent proxy or unknown 165 Origin server connection status :connection open failed 166 ''; 167 in '' 168 runHook preInstallCheck 169 diff -Naur <($out/bin/traffic_via '[uScMsEf p eC:t cCMp sF]') - <<EOF 170 ${lib.removeSuffix "\n" expected} 171 EOF 172 runHook postInstallCheck 173 ''; 174 175 doCheck = true; 176 doInstallCheck = true; 177 enableParallelBuilding = true; 178 179 passthru.tests = { inherit (nixosTests) trafficserver; }; 180 181 meta = with lib; { 182 homepage = "https://trafficserver.apache.org"; 183 changelog = "https://raw.githubusercontent.com/apache/trafficserver/${version}/CHANGELOG-${version}"; 184 description = "Fast, scalable, and extensible HTTP caching proxy server"; 185 longDescription = '' 186 Apache Traffic Server is a high-performance web proxy cache that improves 187 network efficiency and performance by caching frequently-accessed 188 information at the edge of the network. This brings content physically 189 closer to end users, while enabling faster delivery and reduced bandwidth 190 use. Traffic Server is designed to improve content delivery for 191 enterprises, Internet service providers (ISPs), backbone providers, and 192 large intranets by maximizing existing and available bandwidth. 193 ''; 194 license = licenses.asl20; 195 maintainers = with maintainers; [ midchildan ]; 196 platforms = platforms.unix; 197 }; 198}