nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 installShellFiles,
6 pkg-config,
7
8 # Optional dependencies
9 enableApp ? with stdenv.hostPlatform; !isWindows && !isStatic,
10 c-aresMinimal,
11 libev,
12 openssl,
13 zlib,
14 enableGetAssets ? false,
15 libxml2,
16 enableHpack ? false,
17 jansson,
18 enableHttp3 ? false,
19 ngtcp2,
20 nghttp3,
21 quictls,
22 enableJemalloc ? false,
23 jemalloc,
24 enablePython ? false,
25 python3,
26 ncurses,
27
28 # Unit tests ; we have to set TZDIR, which is a GNUism.
29 enableTests ? stdenv.hostPlatform.isGnu,
30 cunit,
31 tzdata,
32
33 # downstream dependencies, for testing
34 curl,
35 libsoup_3,
36}:
37
38# Note: this package is used for bootstrapping fetchurl, and thus cannot use fetchpatch!
39# All mutable patches (generated by GitHub or cgit) that are needed here
40# should be included directly in Nixpkgs as files.
41
42assert enableGetAssets -> enableApp;
43assert enableHpack -> enableApp;
44assert enableHttp3 -> enableApp;
45assert enableJemalloc -> enableApp;
46
47stdenv.mkDerivation rec {
48 pname = "nghttp2";
49 version = "1.65.0";
50
51 src = fetchurl {
52 url = "https://github.com/${pname}/${pname}/releases/download/v${version}/${pname}-${version}.tar.bz2";
53 sha256 = "sha256-C9u3jcIYcEhP1URJBnZXtg47G3Im4RdM9WQBbG0zB/U=";
54 };
55
56 outputs = [
57 "out"
58 "dev"
59 "lib"
60 "doc"
61 "man"
62 ];
63
64 nativeBuildInputs = [ pkg-config ] ++ lib.optionals (enableApp) [ installShellFiles ];
65
66 buildInputs =
67 lib.optionals enableApp [
68 c-aresMinimal
69 libev
70 zlib
71 ]
72 ++ lib.optionals (enableApp && !enableHttp3) [ openssl ]
73 ++ lib.optionals (enableGetAssets) [ libxml2 ]
74 ++ lib.optionals (enableHpack) [ jansson ]
75 ++ lib.optionals (enableJemalloc) [ jemalloc ]
76 ++ lib.optionals (enableHttp3) [
77 ngtcp2
78 nghttp3
79 quictls
80 ]
81 ++ lib.optionals (enablePython) [ python3 ];
82
83 enableParallelBuilding = true;
84
85 configureFlags = [
86 "--disable-examples"
87 (lib.enableFeature enableApp "app")
88 (lib.enableFeature enableHttp3 "http3")
89 ];
90
91 # Unit tests require CUnit and setting TZDIR environment variable
92 doCheck = enableTests;
93 nativeCheckInputs = lib.optionals (enableTests) [
94 cunit
95 tzdata
96 ];
97 preCheck = lib.optionalString (enableTests) ''
98 export TZDIR=${tzdata}/share/zoneinfo
99 '';
100
101 # this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion
102 # necessary for FreeBSD code path in configure
103 postPatch = ''
104 substituteInPlace ./config.guess --replace-fail /usr/bin/uname uname
105 '';
106
107 postInstall =
108 lib.optionalString (enableApp) ''
109 installShellCompletion --bash doc/bash_completion/{h2load,nghttp,nghttpd,nghttpx}
110 ''
111 + lib.optionalString (!enableApp) ''
112 rm -r $out/bin
113 ''
114 + lib.optionalString (enablePython) ''
115 patchShebangs $out/share/nghttp2
116 ''
117 + lib.optionalString (!enablePython) ''
118 rm -r $out/share
119 '';
120
121 passthru.tests = {
122 inherit curl libsoup_3;
123 };
124
125 meta = {
126 description = "HTTP/2 C library and tools";
127 longDescription = ''
128 nghttp2 is an implementation of the HyperText Transfer Protocol version 2 in C.
129 The framing layer of HTTP/2 is implemented as a reusable C library. On top of that,
130 we have implemented an HTTP/2 client, server and proxy. We have also developed
131 load test and benchmarking tools for HTTP/2.
132 An HPACK encoder and decoder are available as a public API.
133 We have Python bindings of this library, but we do not have full code coverage yet.
134 An experimental high level C++ library is also available.
135 '';
136
137 homepage = "https://nghttp2.org/";
138 changelog = "https://github.com/nghttp2/nghttp2/releases/tag/v${version}";
139 # News articles with changes summary can be found here: https://nghttp2.org/blog/archives/
140 license = lib.licenses.mit;
141 maintainers = with lib.maintainers; [ c0bw3b ];
142 platforms = lib.platforms.all;
143 };
144}