base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / ht / http-parser / package.nix
blob69cf2ab210dd48058b6064b2f0d99d4503964a62
1 { lib, stdenv, fetchFromGitHub, fetchpatch
2 , enableShared ? !stdenv.hostPlatform.isStatic
3 , enableStatic ? stdenv.hostPlatform.isStatic
4 }:
6 stdenv.mkDerivation rec {
7   pname = "http-parser";
8   version = "2.9.4";
10   src = fetchFromGitHub {
11     owner = "nodejs";
12     repo = "http-parser";
13     rev = "v${version}";
14     sha256 = "1vda4dp75pjf5fcph73sy0ifm3xrssrmf927qd1x8g3q46z0cv6c";
15   };
17   env.NIX_CFLAGS_COMPILE = "-Wno-error";
19   patches = [
20     ./enable-static-shared.patch
21   ] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
22     # https://github.com/nodejs/http-parser/pull/510
23     (fetchpatch {
24       url = "https://github.com/nodejs/http-parser/commit/4f15b7d510dc7c6361a26a7c6d2f7c3a17f8d878.patch";
25       sha256 = "sha256-rZZMJeow3V1fTnjadRaRa+xTq3pdhZn/eJ4xjxEDoU4=";
26     })
27   ];
29   makeFlags = [
30     "DESTDIR="
31     "PREFIX=$(out)"
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"
45   ];
47   buildFlags = lib.optional enableShared "library"
48     ++ lib.optional enableStatic "package";
50   doCheck = true;
51   checkTarget = "test";
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
58   '';
60   meta = with lib; {
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;
66   };