2015-05-02 03:13:14 +01:00
|
|
|
{ stdenv, fetchurl
|
2010-08-05 21:24:32 +01:00
|
|
|
|
2015-05-02 03:13:14 +01:00
|
|
|
# Optional Dependencies
|
|
|
|
, zlib ? null
|
|
|
|
|
|
|
|
# Crypto Dependencies
|
|
|
|
, openssl ? null, libgcrypt ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2015-06-01 19:52:03 +01: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-02 03:13:14 +01:00
|
|
|
# Prefer openssl
|
|
|
|
cryptoStr = if shouldUsePkg openssl != null then "openssl"
|
|
|
|
else if shouldUsePkg libgcrypt != null then "libgcrypt"
|
|
|
|
else "none";
|
|
|
|
crypto = {
|
|
|
|
openssl = openssl;
|
|
|
|
libgcrypt = libgcrypt;
|
|
|
|
none = null;
|
|
|
|
}.${cryptoStr};
|
|
|
|
|
|
|
|
optZlib = shouldUsePkg zlib;
|
|
|
|
in
|
|
|
|
|
|
|
|
assert crypto != null;
|
|
|
|
|
|
|
|
with stdenv.lib;
|
2010-08-05 21:24:32 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2015-03-26 05:53:13 +00:00
|
|
|
name = "libssh2-1.5.0";
|
2010-08-05 21:24:32 +01:00
|
|
|
|
2015-05-02 03:13:14 +01:00
|
|
|
src = fetchurl {
|
2010-08-05 21:24:32 +01:00
|
|
|
url = "${meta.homepage}/download/${name}.tar.gz";
|
2015-03-26 05:53:13 +00:00
|
|
|
sha256 = "1z6hfgak00yz0azx6lk6n688mywhdxx03j6sdf95p3w6ssnnn6c3";
|
2010-08-05 21:24:32 +01:00
|
|
|
};
|
|
|
|
|
2015-05-02 03:13:14 +01:00
|
|
|
buildInputs = [ crypto optZlib ];
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
(mkWith (cryptoStr == "openssl") "openssl" null)
|
|
|
|
(mkWith (cryptoStr == "libgcrypt") "libgcrypt" null)
|
|
|
|
(mkWith false "wicng" null)
|
|
|
|
(mkWith optZlib "libz" null)
|
|
|
|
(mkEnable false "crypt-none" null)
|
|
|
|
(mkEnable false "mac-none" null)
|
|
|
|
(mkEnable true "gex-new" null)
|
|
|
|
(mkEnable false "debug" null)
|
|
|
|
(mkEnable false "examples-build" null)
|
|
|
|
];
|
|
|
|
|
2015-06-02 10:43:11 +01:00
|
|
|
postInstall = optionalString (optZlib != null) ''
|
|
|
|
sed -i 's,\(-lz\),-L${optZlib}/lib \1,' $out/lib/libssh2.la
|
2015-05-02 03:13:14 +01:00
|
|
|
'' + optionalString (cryptoStr == "openssl") ''
|
2015-06-02 10:43:11 +01:00
|
|
|
sed -i 's,\(-lssl\|-lcrypto\),-L${openssl}/lib \1,' $out/lib/libssh2.la
|
2015-05-02 03:13:14 +01:00
|
|
|
'' + optionalString (cryptoStr == "libgcrypt") ''
|
2015-06-02 10:43:11 +01:00
|
|
|
sed -i 's,\(-lgcrypt\),-L${libgcrypt}/lib \1,' $out/lib/libssh2.la
|
|
|
|
'';
|
2010-08-05 21:24:32 +01:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A client-side C library implementing the SSH2 protocol";
|
|
|
|
homepage = http://www.libssh2.org;
|
2015-05-02 03:13:14 +01:00
|
|
|
license = licenses.gpl2;
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ urkud wkennington ];
|
2010-08-05 21:24:32 +01:00
|
|
|
};
|
|
|
|
}
|