7 # Optional dependencies
8 , enableApp ? with stdenv.hostPlatform; !isWindows && !isStatic
9 , c-aresMinimal, libev, openssl, zlib
10 , enableGetAssets ? false, libxml2
11 , enableHpack ? false, jansson
12 , enableHttp3 ? false, ngtcp2, nghttp3, quictls
13 , enableJemalloc ? false, jemalloc
14 , enablePython ? false, python3, ncurses
16 # Unit tests ; we have to set TZDIR, which is a GNUism.
17 , enableTests ? stdenv.hostPlatform.isGnu, cunit, tzdata
19 # downstream dependencies, for testing
24 # Note: this package is used for bootstrapping fetchurl, and thus cannot use fetchpatch!
25 # All mutable patches (generated by GitHub or cgit) that are needed here
26 # should be included directly in Nixpkgs as files.
28 assert enableGetAssets -> enableApp;
29 assert enableHpack -> enableApp;
30 assert enableHttp3 -> enableApp;
31 assert enableJemalloc -> enableApp;
33 stdenv.mkDerivation rec {
38 url = "https://github.com/${pname}/${pname}/releases/download/v${version}/${pname}-${version}.tar.bz2";
39 sha256 = "sha256-OmcN83joUrhaIpXyXk9RzCj1bg/MSWQIuMN2QpBTevU=";
42 outputs = [ "out" "dev" "lib" "doc" "man" ];
44 nativeBuildInputs = [ pkg-config ]
45 ++ lib.optionals (enableApp) [ installShellFiles ];
47 buildInputs = lib.optionals enableApp [ c-aresMinimal libev zlib ]
48 ++ lib.optionals (enableApp && !enableHttp3) [ openssl ]
49 ++ lib.optionals (enableGetAssets) [ libxml2 ]
50 ++ lib.optionals (enableHpack) [ jansson ]
51 ++ lib.optionals (enableJemalloc) [ jemalloc ]
52 ++ lib.optionals (enableHttp3) [ ngtcp2 nghttp3 quictls ]
53 ++ lib.optionals (enablePython) [ python3 ];
55 enableParallelBuilding = true;
59 (lib.enableFeature enableApp "app")
60 (lib.enableFeature enableHttp3 "http3")
63 env.NIX_CFLAGS_COMPILE = toString (lib.optionals (stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
64 "-faligned-allocation"
67 # Unit tests require CUnit and setting TZDIR environment variable
68 doCheck = enableTests;
69 nativeCheckInputs = lib.optionals (enableTests) [ cunit tzdata ];
70 preCheck = lib.optionalString (enableTests) ''
71 export TZDIR=${tzdata}/share/zoneinfo
74 # this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion
75 # necessary for FreeBSD code path in configure
77 substituteInPlace ./config.guess --replace-fail /usr/bin/uname uname
80 postInstall = lib.optionalString (enableApp) ''
81 installShellCompletion --bash doc/bash_completion/{h2load,nghttp,nghttpd,nghttpx}
82 '' + lib.optionalString (!enableApp) ''
84 '' + lib.optionalString (enablePython) ''
85 patchShebangs $out/share/nghttp2
86 '' + lib.optionalString (!enablePython) ''
95 description = "HTTP/2 C library and tools";
97 nghttp2 is an implementation of the HyperText Transfer Protocol version 2 in C.
98 The framing layer of HTTP/2 is implemented as a reusable C library. On top of that,
99 we have implemented an HTTP/2 client, server and proxy. We have also developed
100 load test and benchmarking tools for HTTP/2.
101 An HPACK encoder and decoder are available as a public API.
102 We have Python bindings of this library, but we do not have full code coverage yet.
103 An experimental high level C++ library is also available.
106 homepage = "https://nghttp2.org/";
107 changelog = "https://github.com/nghttp2/nghttp2/releases/tag/v${version}";
108 # News articles with changes summary can be found here: https://nghttp2.org/blog/archives/
109 license = licenses.mit;
110 maintainers = with maintainers; [ c0bw3b ];
111 platforms = platforms.all;