2015-05-20 07:30:51 +01:00
|
|
|
{ stdenv, fetchurl, pkgconfig, cmake
|
|
|
|
|
|
|
|
# Optional Dependencies
|
|
|
|
, heimdal ? null, zlib ? null, libsodium ? null
|
|
|
|
|
|
|
|
# Crypto Dependencies
|
|
|
|
, openssl ? null, libgcrypt ? null
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2015-06-01 19:52:03 +01:00
|
|
|
shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
|
|
|
|
|
2015-05-20 07:30:51 +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};
|
|
|
|
|
|
|
|
optHeimdal = shouldUsePkg heimdal;
|
|
|
|
optZlib = shouldUsePkg zlib;
|
|
|
|
optLibsodium = shouldUsePkg libsodium;
|
|
|
|
in
|
|
|
|
|
|
|
|
assert crypto != null;
|
2010-02-14 21:56:35 +00:00
|
|
|
|
2011-06-07 22:49:42 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2015-05-20 07:30:51 +01:00
|
|
|
name = "libssh-0.7.0";
|
2012-11-29 15:21:01 +00:00
|
|
|
|
2010-02-14 21:56:35 +00:00
|
|
|
src = fetchurl {
|
2015-05-24 21:20:49 +01:00
|
|
|
url = "https://git.libssh.org/projects/libssh.git/snapshot/libssh-0.7.0.tar.gz";
|
|
|
|
sha256 = "1wfrdqhv97f4ycd9bcpgb6gw47kr7b2iq8cz5knk8a6n9c6870k0";
|
2010-02-14 21:56:35 +00:00
|
|
|
};
|
2012-11-29 15:21:01 +00:00
|
|
|
|
2015-05-26 22:13:16 +01:00
|
|
|
patches = [ ./0001-Reintroduce-ssh_forward_listen-Fixes-194.patch ];
|
|
|
|
|
2015-05-22 00:13:52 +01:00
|
|
|
postPatch = ''
|
|
|
|
# Fix headers to use libsodium instead of NaCl
|
|
|
|
sed -i 's,nacl/,sodium/,g' ./include/libssh/curve25519.h src/curve25519.c
|
|
|
|
'';
|
2015-05-20 07:30:51 +01:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DWITH_GSSAPI=${if optHeimdal != null then "ON" else "OFF"}"
|
|
|
|
"-DWITH_ZLIB=${if optZlib != null then "ON" else "OFF"}"
|
|
|
|
"-DWITH_SSH1=OFF"
|
|
|
|
"-DWITH_SFTP=ON"
|
|
|
|
"-DWITH_SERVER=ON"
|
|
|
|
"-DWITH_STATIC_LIB=OFF"
|
|
|
|
"-DWITH_DEBUG_CRYPTO=OFF"
|
|
|
|
"-DWITH_DEBUG_CALLTRACE=OFF"
|
|
|
|
"-DWITH_GCRYPT=${if cryptoStr == "libgcrypt" then "ON" else "OFF"}"
|
|
|
|
"-DWITH_PCAP=ON"
|
|
|
|
"-DWITH_INTERNAL_DOC=OFF"
|
|
|
|
"-DWITH_TESTING=OFF"
|
|
|
|
"-DWITH_CLIENT_TESTING=OFF"
|
|
|
|
"-DWITH_BENCHMARKS=OFF"
|
|
|
|
"-DWITH_EXAMPLES=OFF"
|
|
|
|
"-DWITH_NACL=${if optLibsodium != null then "ON" else "OFF"}"
|
|
|
|
] ++ stdenv.lib.optionals (optLibsodium != null) [
|
2015-05-22 00:13:52 +01:00
|
|
|
"-DNACL_LIBRARY=${optLibsodium}/lib/libsodium.so"
|
2015-05-20 07:30:51 +01:00
|
|
|
"-DNACL_INCLUDE_DIR=${optLibsodium}/include"
|
|
|
|
];
|
2012-11-29 15:21:01 +00:00
|
|
|
|
2015-05-22 00:13:52 +01:00
|
|
|
nativeBuildInputs = [ pkgconfig cmake ];
|
|
|
|
buildInputs = [ optHeimdal optZlib optLibsodium crypto ];
|
2012-11-29 15:21:01 +00:00
|
|
|
|
2014-12-20 13:35:20 +00:00
|
|
|
meta = with stdenv.lib; {
|
2010-02-14 21:56:35 +00:00
|
|
|
description = "SSH client library";
|
2014-12-20 13:35:20 +00:00
|
|
|
license = licenses.lgpl2Plus;
|
2015-05-20 07:30:51 +01:00
|
|
|
maintainers = with maintainers; [ sander urkud wkennington ];
|
2014-12-20 13:35:20 +00:00
|
|
|
platforms = platforms.all;
|
2010-02-14 21:56:35 +00:00
|
|
|
};
|
|
|
|
}
|