2022-04-15 01:41:22 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, installShellFiles
|
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Optional dependencies
|
|
|
|
, enableApp ? with stdenv.hostPlatform; !isWindows && !isStatic
|
2022-10-30 15:09:59 +00:00
|
|
|
, c-aresMinimal, libev, openssl, zlib
|
2022-05-18 14:49:53 +00:00
|
|
|
, enableGetAssets ? false, libxml2
|
|
|
|
, enableHpack ? false, jansson
|
2023-08-10 07:59:29 +00:00
|
|
|
, enableHttp3 ? false, ngtcp2, nghttp3, quictls
|
2022-05-18 14:49:53 +00:00
|
|
|
, enableJemalloc ? false, jemalloc
|
2023-08-10 07:59:29 +00:00
|
|
|
, enablePython ? false, python3, ncurses
|
2022-03-10 19:12:11 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Unit tests ; we have to set TZDIR, which is a GNUism.
|
2022-05-18 14:49:53 +00:00
|
|
|
, enableTests ? stdenv.hostPlatform.isGnu, cunit, tzdata
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-03-10 19:12:11 +00:00
|
|
|
# downstream dependencies, for testing
|
|
|
|
, curl
|
|
|
|
, libsoup
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Note: this package is used for bootstrapping fetchurl, and thus cannot use fetchpatch!
|
|
|
|
# All mutable patches (generated by GitHub or cgit) that are needed here
|
|
|
|
# should be included directly in Nixpkgs as files.
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
assert enableGetAssets -> enableApp;
|
|
|
|
assert enableHpack -> enableApp;
|
2023-08-10 07:59:29 +00:00
|
|
|
assert enableHttp3 -> enableApp;
|
2022-05-18 14:49:53 +00:00
|
|
|
assert enableJemalloc -> enableApp;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "nghttp2";
|
2024-10-11 05:15:48 +00:00
|
|
|
version = "1.63.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/${pname}/${pname}/releases/download/v${version}/${pname}-${version}.tar.bz2";
|
2024-10-11 05:15:48 +00:00
|
|
|
sha256 = "sha256-YHsXRVTSKoKLxTLR1zT+D3KbXV7SB/LxLpamLoPynFU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
outputs = [ "out" "dev" "lib" "doc" "man" ];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ pkg-config ]
|
2023-08-10 07:59:29 +00:00
|
|
|
++ lib.optionals (enableApp) [ installShellFiles ];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
buildInputs = lib.optionals enableApp [ c-aresMinimal libev zlib ]
|
|
|
|
++ lib.optionals (enableApp && !enableHttp3) [ openssl ]
|
2022-04-15 01:41:22 +00:00
|
|
|
++ lib.optionals (enableGetAssets) [ libxml2 ]
|
|
|
|
++ lib.optionals (enableHpack) [ jansson ]
|
|
|
|
++ lib.optionals (enableJemalloc) [ jemalloc ]
|
2023-08-10 07:59:29 +00:00
|
|
|
++ lib.optionals (enableHttp3) [ ngtcp2 nghttp3 quictls ]
|
|
|
|
++ lib.optionals (enablePython) [ python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--disable-examples"
|
2021-02-05 17:12:51 +00:00
|
|
|
(lib.enableFeature enableApp "app")
|
2023-08-10 07:59:29 +00:00
|
|
|
(lib.enableFeature enableHttp3 "http3")
|
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2024-09-26 11:04:55 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString (lib.optionals (stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
|
2024-07-31 10:19:44 +00:00
|
|
|
"-faligned-allocation"
|
|
|
|
]);
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# Unit tests require CUnit and setting TZDIR environment variable
|
|
|
|
doCheck = enableTests;
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = lib.optionals (enableTests) [ cunit tzdata ];
|
2022-04-15 01:41:22 +00:00
|
|
|
preCheck = lib.optionalString (enableTests) ''
|
|
|
|
export TZDIR=${tzdata}/share/zoneinfo
|
|
|
|
'';
|
|
|
|
|
2024-06-20 14:57:18 +00:00
|
|
|
# this could be accomplished by updateAutotoolsGnuConfigScriptsHook, but that causes infinite recursion
|
|
|
|
# necessary for FreeBSD code path in configure
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace ./config.guess --replace-fail /usr/bin/uname uname
|
|
|
|
'';
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
postInstall = lib.optionalString (enableApp) ''
|
2022-04-15 01:41:22 +00:00
|
|
|
installShellCompletion --bash doc/bash_completion/{h2load,nghttp,nghttpd,nghttpx}
|
2023-08-10 07:59:29 +00:00
|
|
|
'' + lib.optionalString (!enableApp) ''
|
|
|
|
rm -r $out/bin
|
|
|
|
'' + lib.optionalString (enablePython) ''
|
|
|
|
patchShebangs $out/share/nghttp2
|
|
|
|
'' + lib.optionalString (!enablePython) ''
|
|
|
|
rm -r $out/share
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-03-10 19:12:11 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit curl libsoup;
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-04-15 01:41:22 +00:00
|
|
|
description = "HTTP/2 C library and tools";
|
|
|
|
longDescription = ''
|
|
|
|
nghttp2 is an implementation of the HyperText Transfer Protocol version 2 in C.
|
|
|
|
The framing layer of HTTP/2 is implemented as a reusable C library. On top of that,
|
|
|
|
we have implemented an HTTP/2 client, server and proxy. We have also developed
|
|
|
|
load test and benchmarking tools for HTTP/2.
|
|
|
|
An HPACK encoder and decoder are available as a public API.
|
|
|
|
We have Python bindings of this library, but we do not have full code coverage yet.
|
|
|
|
An experimental high level C++ library is also available.
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://nghttp2.org/";
|
2022-04-15 01:41:22 +00:00
|
|
|
changelog = "https://github.com/nghttp2/nghttp2/releases/tag/v${version}";
|
|
|
|
# News articles with changes summary can be found here: https://nghttp2.org/blog/archives/
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2022-04-15 01:41:22 +00:00
|
|
|
maintainers = with maintainers; [ c0bw3b ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|