@@ -1,73 +1,19 @@
1−{ stdenv, fetchurl
1+{stdenv, fetchurlBoot, openssl, zlib}:
22
3−# Optional Dependencies
4−, zlib ? null
5−
6−# Crypto Dependencies
7−, openssl ? null, libgcrypt ? null
8−}:
9−
10−let
11− mkFlag = trueStr: falseStr: cond: name: val:
12− if cond == null then null else
13− "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
14− mkEnable = mkFlag "enable-" "disable-";
15− mkWith = mkFlag "with-" "without-";
16− mkOther = mkFlag "" "" true;
17−
18− shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
19−
20− # Prefer openssl
21− cryptoStr = if shouldUsePkg openssl != null then "openssl"
22− else if shouldUsePkg libgcrypt != null then "libgcrypt"
23− else "none";
24− crypto = {
25− openssl = openssl;
26− libgcrypt = libgcrypt;
27− none = null;
28− }.${cryptoStr};
29−
30− optZlib = shouldUsePkg zlib;
31−in
32−
33−assert crypto != null;
34−
35−with stdenv.lib;
363stdenv.mkDerivation rec {
374 name = "libssh2-1.5.0";
385
39− src = fetchurl {
6+ src = fetchurlBoot {
407 url = "${meta.homepage}/download/${name}.tar.gz";
418 sha256 = "1z6hfgak00yz0azx6lk6n688mywhdxx03j6sdf95p3w6ssnnn6c3";
429 };
4310
44− buildInputs = [ crypto optZlib ];
45−
46− configureFlags = [
47− (mkWith (cryptoStr == "openssl") "openssl" null)
48− (mkWith (cryptoStr == "libgcrypt") "libgcrypt" null)
49− (mkWith false "wicng" null)
50− (mkWith optZlib "libz" null)
51− (mkEnable false "crypt-none" null)
52− (mkEnable false "mac-none" null)
53− (mkEnable true "gex-new" null)
54− (mkEnable false "debug" null)
55− (mkEnable false "examples-build" null)
56− ];
57−
58− postInstall = optionalString (optZlib != null) ''
59− sed -i 's,\(-lz\),-L${optZlib}/lib \1,' $out/lib/libssh2.la
60− '' + optionalString (cryptoStr == "openssl") ''
61− sed -i 's,\(-lssl\|-lcrypto\),-L${openssl}/lib \1,' $out/lib/libssh2.la
62− '' + optionalString (cryptoStr == "libgcrypt") ''
63− sed -i 's,\(-lgcrypt\),-L${libgcrypt}/lib \1,' $out/lib/libssh2.la
64− '';
11+ buildInputs = [ openssl zlib ];
6512
6613 meta = {
6714 description = "A client-side C library implementing the SSH2 protocol";
6815 homepage = http://www.libssh2.org;
69− license = licenses.gpl2;
70− platforms = platforms.all;
71− maintainers = with maintainers; [ urkud wkennington ];
16+ platforms = stdenv.lib.platforms.all;
17+ maintainers = [ stdenv.lib.maintainers.urkud ];
7218 };
7319}