1{
2 lib,
3 stdenv,
4 fetchurl,
5 pkg-config,
6 cmake,
7 zlib,
8 openssl,
9 libsodium,
10
11 # for passthru.tests
12 ffmpeg,
13 sshping,
14 wireshark,
15}:
16
17stdenv.mkDerivation rec {
18 pname = "libssh";
19 version = "0.11.2";
20
21 src = fetchurl {
22 url = "https://www.libssh.org/files/${lib.versions.majorMinor version}/libssh-${version}.tar.xz";
23 hash = "sha256-aVKfwY9bYB8Lrw5aRQGivCbfXi8Rb1+PB/Gfr6ptBOc=";
24 };
25
26 outputs = [
27 "out"
28 "dev"
29 ];
30
31 postPatch = ''
32 # Fix headers to use libsodium instead of NaCl
33 sed -i 's,nacl/,sodium/,g' ./include/libssh/curve25519.h src/curve25519.c
34 '';
35
36 # Don’t build examples, which are not installed and require additional dependencies not
37 # included in `buildInputs` such as libX11.
38 cmakeFlags = [ "-DWITH_EXAMPLES=OFF" ];
39
40 buildInputs = [
41 zlib
42 openssl
43 libsodium
44 ];
45
46 nativeBuildInputs = [
47 cmake
48 pkg-config
49 ];
50
51 postFixup = ''
52 substituteInPlace $dev/lib/cmake/libssh/libssh-config.cmake \
53 --replace-fail "set(_IMPORT_PREFIX \"$out\")" "set(_IMPORT_PREFIX \"$dev\")"
54 '';
55
56 passthru.tests = {
57 inherit ffmpeg sshping wireshark;
58 };
59
60 meta = with lib; {
61 description = "SSH client library";
62 homepage = "https://libssh.org";
63 license = licenses.lgpl2Plus;
64 maintainers = with maintainers; [ sander ];
65 platforms = platforms.all;
66 };
67}