···
15
+
# recommended dependencies
22
+
, withCap ? stdenv.isLinux
24
+
, withUnwind ? stdenv.isLinux
26
+
# optional dependencies
27
+
, withBrotli ? false
33
+
, withHiredis ? false
35
+
, withImageMagick ? false
37
+
, withJansson ? false
39
+
, withKyotoCabinet ? false
41
+
, withLuaJIT ? false
43
+
, withMaxmindDB ? false
46
+
, enableWCCP ? false
49
+
stdenv.mkDerivation rec {
50
+
pname = "trafficserver";
54
+
url = "mirror://apache/trafficserver/trafficserver-${version}.tar.bz2";
55
+
sha256 = "1q164pvfmbqh3gzy3bqy96lwd0fdbhz78r06pd92p7rmkqwx005z";
59
+
# Adds support for NixOS
60
+
# https://github.com/apache/trafficserver/pull/7697
62
+
url = "https://github.com/apache/trafficserver/commit/19d3af481cf74c91fbf713fc9d2f8b138ed5fbaf.diff";
63
+
sha256 = "0z1ikgpp00rzrrcqh97931586yn9wbksgai9xlkcjd5cg8gq0150";
66
+
# Fixes a bug in tspush which pushes incorrect contents to cache
67
+
# https://github.com/apache/trafficserver/pull/7696
69
+
url = "https://github.com/apache/trafficserver/commit/b08215272872f452787915cd3a8e0b0ea0b88385.diff";
70
+
sha256 = "0axk8x1xvd8wvpgcxgyqqg7kgxyxwfgwmisq3xnk1da0cqv9cx9f";
74
+
# NOTE: The upstream README indicates that flex is needed for some features,
75
+
# but it actually seems to be unnecessary as of this commit[1]. The detection
76
+
# logic for bison and flex is still present in the build script[2], but no
77
+
# other code seems to depend on it. This situation is susceptible to change
78
+
# though, so it's a good idea to inspect the build scripts periodically.
80
+
# [1]: https://github.com/apache/trafficserver/pull/5617
81
+
# [2]: https://github.com/apache/trafficserver/blob/3fd2c60/configure.ac#L742-L788
82
+
nativeBuildInputs = [ makeWrapper pkg-config file python3 ]
83
+
++ (with perlPackages; [ perl ExtUtilsMakeMaker ])
84
+
++ lib.optionals stdenv.isLinux [ linuxHeaders ];
90
+
] ++ lib.optional withBrotli brotli
91
+
++ lib.optional withCap libcap
92
+
++ lib.optional withCjose cjose
93
+
++ lib.optional withCurl curl
94
+
++ lib.optional withGeoIP geoip
95
+
++ lib.optional withHiredis hiredis
96
+
++ lib.optional withHwloc hwloc
97
+
++ lib.optional withImageMagick imagemagick
98
+
++ lib.optional withJansson jansson
99
+
++ lib.optional withKyotoCabinet kyotocabinet
100
+
++ lib.optional withCurses ncurses
101
+
++ lib.optional withLuaJIT luajit
102
+
++ lib.optional withUnwind libunwind
103
+
++ lib.optional withMaxmindDB libmaxminddb;
105
+
outputs = [ "out" "man" ];
109
+
iocore/aio/test_AIO.sample \
110
+
src/traffic_via/test_traffic_via \
111
+
src/traffic_logstats/tests \
112
+
tools/check-unused-dependencies
114
+
substituteInPlace configure --replace '/usr/bin/file' '${file}/bin/file'
115
+
'' + lib.optionalString stdenv.isLinux ''
116
+
substituteInPlace configure \
117
+
--replace '/usr/include/linux' '${linuxHeaders}/include/linux'
118
+
'' + lib.optionalString stdenv.isDarwin ''
119
+
# 'xcrun leaks' probably requires non-free XCode
120
+
substituteInPlace iocore/net/test_certlookup.cc \
121
+
--replace 'xcrun leaks' 'true'
125
+
"--enable-layout=NixOS"
126
+
"--enable-experimental-plugins"
127
+
(lib.enableFeature enableWCCP "wccp")
129
+
# the configure script can't auto-locate the following from buildInputs
130
+
"--with-lzma=${xz.dev}"
131
+
"--with-zlib=${zlib.dev}"
132
+
(lib.withFeatureAs withHiredis "hiredis" hiredis)
136
+
"pkgsysconfdir=${placeholder "out"}/etc/trafficserver"
138
+
# replace runtime directories with an install-time placeholder directory
139
+
"pkgcachedir=${placeholder "out"}/.install-trafficserver"
140
+
"pkglocalstatedir=${placeholder "out"}/.install-trafficserver"
141
+
"pkglogdir=${placeholder "out"}/.install-trafficserver"
142
+
"pkgruntimedir=${placeholder "out"}/.install-trafficserver"
146
+
substituteInPlace rc/trafficserver.service --replace "syslog.target" ""
147
+
install -Dm644 rc/trafficserver.service $out/lib/systemd/system/trafficserver.service
149
+
wrapProgram $out/bin/tspush \
150
+
--set PERL5LIB '${with perlPackages; makePerlPath [ URI ]}' \
151
+
--prefix PATH : "${lib.makeBinPath [ file ]}"
153
+
find "$out" -name '*.la' -delete
155
+
# ensure no files actually exist in this directory
156
+
rmdir $out/.install-trafficserver
159
+
installCheckPhase = let
161
+
Via header is [uScMsEf p eC:t cCMp sF], Length is 22
162
+
Via Header Details:
163
+
Request headers received from client :simple request (not conditional)
164
+
Result of Traffic Server cache lookup for URL :miss (a cache "MISS")
165
+
Response information received from origin server :error in response
166
+
Result of document write-to-cache: :no cache write performed
167
+
Proxy operation result :unknown
168
+
Error codes (if any) :connection to server failed
169
+
Tunnel info :no tunneling
171
+
Cache Lookup Result :cache miss (url not in cache)
172
+
Parent proxy connection status :no parent proxy or unknown
173
+
Origin server connection status :connection open failed
176
+
runHook preInstallCheck
177
+
diff -Naur <($out/bin/traffic_via '[uScMsEf p eC:t cCMp sF]') - <<EOF
178
+
${lib.removeSuffix "\n" expected}
180
+
runHook postInstallCheck
184
+
doInstallCheck = true;
185
+
enableParallelBuilding = true;
188
+
homepage = "https://trafficserver.apache.org";
189
+
changelog = "https://raw.githubusercontent.com/apache/trafficserver/${version}/CHANGELOG-${version}";
190
+
description = "Fast, scalable, and extensible HTTP caching proxy server";
191
+
longDescription = ''
192
+
Apache Traffic Server is a high-performance web proxy cache that improves
193
+
network efficiency and performance by caching frequently-accessed
194
+
information at the edge of the network. This brings content physically
195
+
closer to end users, while enabling faster delivery and reduced bandwidth
196
+
use. Traffic Server is designed to improve content delivery for
197
+
enterprises, Internet service providers (ISPs), backbone providers, and
198
+
large intranets by maximizing existing and available bandwidth.
200
+
license = licenses.asl20;
201
+
maintainers = with maintainers; [ midchildan ];
202
+
platforms = platforms.unix;