libmicrohttpd: Modernize

+48 -21
+48 -21
pkgs/development/libraries/libmicrohttpd/default.nix
··· 1 - {stdenv, fetchurl, curl, libgcrypt}: 1 + { stdenv, fetchurl, pkgconfig 2 + , curl 3 + 4 + # Optional Dependencies 5 + , openssl ? null, zlib ? null, libgcrypt ? null, gnutls ? null 6 + }: 7 + 8 + let 9 + mkFlag = trueStr: falseStr: cond: name: val: 10 + if cond == null then null else 11 + "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}"; 12 + mkEnable = mkFlag "enable-" "disable-"; 13 + mkWith = mkFlag "with-" "without-"; 14 + mkOther = mkFlag "" "" true; 15 + 16 + shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null; 17 + 18 + optOpenssl = shouldUsePkg openssl; 19 + optZlib = shouldUsePkg zlib; 20 + hasSpdy = optOpenssl != null && optZlib != null; 2 21 22 + optLibgcrypt = shouldUsePkg libgcrypt; 23 + optGnutls = shouldUsePkg gnutls; 24 + hasHttps = optLibgcrypt != null && optGnutls != null; 25 + in 26 + with stdenv.lib; 3 27 stdenv.mkDerivation rec { 4 - name = "libmicrohttpd-0.9.38"; 28 + name = "libmicrohttpd-0.9.41"; 5 29 6 30 src = fetchurl { 7 31 url = "mirror://gnu/libmicrohttpd/${name}.tar.gz"; 8 - sha256 = "08g7p4l0p2fsjj8ayl68zq1bqgrn0pck19bm8yd7k61whvfv9wld"; 32 + sha256 = "0z3s3aplgxj8cj947i4rxk9wzvg68b8hbn71fyipc7aagmivx64p"; 9 33 }; 10 34 11 - buildInputs = [ curl libgcrypt ]; 35 + nativeBuildInputs = [ pkgconfig ]; 36 + buildInputs = optional doCheck curl 37 + ++ optionals hasSpdy [ optOpenssl optZlib ] 38 + ++ optionals hasHttps [ optLibgcrypt optGnutls ]; 12 39 13 - preCheck = 14 - # Since `localhost' can't be resolved in a chroot, work around it. 15 - '' for i in "src/test"*"/"*.[ch] 16 - do 17 - sed -i "$i" -es/localhost/127.0.0.1/g 18 - done 19 - ''; 40 + configureFlags = [ 41 + (mkWith true "threads" "posix") 42 + (mkEnable true "doc" null) 43 + (mkEnable false "examples" null) 44 + (mkEnable true "epoll" "auto") 45 + (mkEnable doCheck "curl" null) 46 + (mkEnable hasSpdy "spdy" null) 47 + (mkEnable true "messages" null) 48 + (mkEnable true "postprocessor" null) 49 + (mkWith hasHttps "gnutls" null) 50 + (mkEnable hasHttps "https" null) 51 + (mkEnable true "bauth" null) 52 + (mkEnable true "dauth" null) 53 + ]; 20 54 21 55 # Disabled because the tests can time-out. 22 56 doCheck = false; 23 57 24 58 meta = { 25 59 description = "Embeddable HTTP server library"; 26 - 27 - longDescription = '' 28 - GNU libmicrohttpd is a small C library that is supposed to make 29 - it easy to run an HTTP server as part of another application. 30 - ''; 31 - 32 - license = stdenv.lib.licenses.lgpl2Plus; 33 - 34 60 homepage = http://www.gnu.org/software/libmicrohttpd/; 35 - 36 - maintainers = [ ]; 61 + license = licenses.lgpl2Plus; 62 + platforms = platforms.all; 63 + maintainers = with maintainers; [ wkennington ]; 37 64 }; 38 65 }