1 { lib, stdenv, fetchFromGitHub, fetchpatch
2 , enableShared ? !stdenv.hostPlatform.isStatic
3 , enableStatic ? stdenv.hostPlatform.isStatic
6 stdenv.mkDerivation rec {
10 src = fetchFromGitHub {
14 sha256 = "1vda4dp75pjf5fcph73sy0ifm3xrssrmf927qd1x8g3q46z0cv6c";
17 env.NIX_CFLAGS_COMPILE = "-Wno-error";
20 ./enable-static-shared.patch
21 ] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
22 # https://github.com/nodejs/http-parser/pull/510
24 url = "https://github.com/nodejs/http-parser/commit/4f15b7d510dc7c6361a26a7c6d2f7c3a17f8d878.patch";
25 sha256 = "sha256-rZZMJeow3V1fTnjadRaRa+xTq3pdhZn/eJ4xjxEDoU4=";
32 "BINEXT=${stdenv.hostPlatform.extensions.executable}"
33 "Platform=${lib.toLower stdenv.hostPlatform.uname.system}"
34 "AEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.staticLibrary}"
35 "ENABLE_SHARED=${if enableShared then "1" else "0"}"
36 "ENABLE_STATIC=${if enableStatic then "1" else "0"}"
37 ] ++ lib.optionals enableShared [
38 "SOEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.sharedLibrary}"
39 ] ++ lib.optionals enableStatic [
40 "AEXT=${lib.strings.removePrefix "." stdenv.hostPlatform.extensions.staticLibrary}"
41 ] ++ lib.optionals (enableShared && stdenv.hostPlatform.isWindows) [
42 "SONAME=$(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOEXT)"
43 "LIBNAME=$(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOREV).$(SOEXT)"
44 "LDFLAGS=-Wl,--out-implib=$(LIBNAME).a"
47 buildFlags = lib.optional enableShared "library"
48 ++ lib.optional enableStatic "package";
53 enableParallelBuilding = true;
55 postInstall = lib.optionalString stdenv.hostPlatform.isWindows ''
56 install -D *.dll.a $out/lib
57 ln -sf libhttp_parser.${version}.dll.a $out/lib/libhttp_parser.dll.a
61 description = "HTTP message parser written in C";
62 homepage = "https://github.com/nodejs/http-parser";
63 maintainers = with maintainers; [ matthewbauer ];
64 license = licenses.mit;
65 platforms = platforms.all;