1{ stdenv, fetchurl, gyp, utillinux, python, fixDarwinDylibNames }:
2
3let
4 version = "2.5.0";
5in stdenv.mkDerivation {
6 name = "http-parser-${version}";
7
8 src = fetchurl {
9 url = "https://github.com/joyent/http-parser/archive/v${version}.tar.gz";
10 sha256 = "108lh05pl4i5w7hmkw07k9wklk5pbh705pw1qyz5zvp6yicbmd73";
11 };
12
13 patches = [ ./build-shared.patch ];
14
15 configurePhase = "gyp -f make --depth=`pwd` http_parser.gyp";
16
17 buildFlags = [ "BUILDTYPE=Release" ];
18
19 buildInputs =
20 [ gyp ]
21 ++ stdenv.lib.optional stdenv.isLinux utillinux
22 ++ stdenv.lib.optionals stdenv.isDarwin [ python fixDarwinDylibNames ];
23
24 doCheck = !stdenv.isDarwin;
25
26 checkPhase = ''
27 out/Release/test-nonstrict
28 out/Release/test-strict
29 '';
30
31 installPhase = ''
32 mkdir -p $out/lib
33 mv out/Release/${if stdenv.isDarwin then "*.dylib" else "lib.target/*"} $out/lib
34
35 mkdir -p $out/include
36 mv http_parser.h $out/include
37 '';
38
39 meta = {
40 description = "An HTTP message parser written in C";
41
42 homepage = https://github.com/joyent/http-parser;
43
44 license = stdenv.lib.licenses.mit;
45 };
46}