2015-05-01 23:35:56 +02:00
|
|
|
{ stdenv, fetchurl, pkgconfig
|
|
|
|
|
|
|
|
# Optinal Dependencies
|
|
|
|
, openssl ? null, libev ? null, zlib ? null, jansson ? null, boost ? null
|
|
|
|
, libxml2 ? null, jemalloc ? null
|
|
|
|
|
|
|
|
# Extra argument
|
|
|
|
, prefix ? ""
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2015-06-01 20:52:03 +02:00
|
|
|
mkFlag = trueStr: falseStr: cond: name: val:
|
|
|
|
if cond == null then null else
|
|
|
|
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
|
|
|
|
mkEnable = mkFlag "enable-" "disable-";
|
|
|
|
mkWith = mkFlag "with-" "without-";
|
|
|
|
mkOther = mkFlag "" "" true;
|
|
|
|
|
|
|
|
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
|
|
|
|
|
2015-05-01 23:35:56 +02:00
|
|
|
isLib = prefix == "lib";
|
|
|
|
|
|
|
|
optOpenssl = if isLib then null else shouldUsePkg openssl;
|
|
|
|
optLibev = if isLib then null else shouldUsePkg libev;
|
|
|
|
optZlib = if isLib then null else shouldUsePkg zlib;
|
|
|
|
|
|
|
|
hasApp = optOpenssl != null && optLibev != null && optZlib != null;
|
|
|
|
|
|
|
|
optJansson = if isLib then null else shouldUsePkg jansson;
|
|
|
|
#optBoost = if isLib then null else shouldUsePkg boost;
|
|
|
|
optBoost = null; # Currently detection is broken
|
|
|
|
optLibxml2 = if !hasApp then null else shouldUsePkg libxml2;
|
|
|
|
optJemalloc = if !hasApp then null else shouldUsePkg jemalloc;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "${prefix}nghttp2-${version}";
|
2015-10-17 20:54:03 +02:00
|
|
|
version = "1.3.4";
|
2015-05-01 23:35:56 +02:00
|
|
|
|
|
|
|
# Don't use fetchFromGitHub since this needs a bootstrap curl
|
|
|
|
src = fetchurl {
|
2015-05-13 20:32:46 +02:00
|
|
|
url = "http://pub.wak.io/nixos/tarballs/nghttp2-${version}.tar.bz2";
|
2015-10-17 20:54:03 +02:00
|
|
|
sha256 = "63c1d70e50f0c8514e261be88b66720df095269791aa008d76c09e0c3a4c085f";
|
2015-05-01 23:35:56 +02:00
|
|
|
};
|
|
|
|
|
2015-05-14 22:35:35 +02:00
|
|
|
# Configure script searches for a symbol which does not exist in jemalloc on Darwin
|
|
|
|
# Reported upstream in https://github.com/tatsuhiro-t/nghttp2/issues/233
|
|
|
|
postPatch = if (stdenv.isDarwin && optJemalloc != null) then ''
|
|
|
|
substituteInPlace configure --replace "malloc_stats_print" "je_malloc_stats_print"
|
|
|
|
'' else null;
|
|
|
|
|
2015-05-01 23:35:56 +02:00
|
|
|
nativeBuildInputs = [ pkgconfig ];
|
|
|
|
buildInputs = [ optJansson optBoost optLibxml2 optJemalloc ]
|
2015-06-01 20:52:03 +02:00
|
|
|
++ stdenv.lib.optionals hasApp [ optOpenssl optLibev optZlib ];
|
2015-05-01 23:35:56 +02:00
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
(mkEnable false "werror" null)
|
|
|
|
(mkEnable false "debug" null)
|
|
|
|
(mkEnable true "threads" null)
|
|
|
|
(mkEnable hasApp "app" null)
|
|
|
|
(mkEnable (optJansson != null) "hpack-tools" null)
|
|
|
|
(mkEnable (optBoost != null) "asio-lib" null)
|
|
|
|
(mkEnable false "examples" null)
|
|
|
|
(mkEnable false "python-bindings" null)
|
|
|
|
(mkEnable false "failmalloc" null)
|
|
|
|
(mkWith (optLibxml2 != null) "libxml2" null)
|
|
|
|
(mkWith (optJemalloc != null) "jemalloc" null)
|
|
|
|
(mkWith false "spdylay" null)
|
|
|
|
(mkWith false "cython" null)
|
2015-10-17 20:54:03 +02:00
|
|
|
(mkWith false "mruby" null)
|
2015-05-01 23:35:56 +02:00
|
|
|
];
|
|
|
|
|
2015-06-01 20:52:03 +02:00
|
|
|
meta = with stdenv.lib; {
|
2015-05-01 23:35:56 +02:00
|
|
|
homepage = http://nghttp2.org/;
|
|
|
|
description = "an implementation of HTTP/2 in C";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ wkennington ];
|
|
|
|
};
|
|
|
|
}
|