btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / libssh / package.nix
blobad6a4322bc1a4d49814601822b92012803e7132c
1 { lib
2 , stdenv
3 , fetchurl
4 , pkg-config
5 , cmake
6 , zlib
7 , openssl
8 , libsodium
10 # for passthru.tests
11 , ffmpeg
12 , sshping
13 , wireshark
16 stdenv.mkDerivation rec {
17   pname = "libssh";
18   version = "0.11.1";
20   src = fetchurl {
21     url = "https://www.libssh.org/files/${lib.versions.majorMinor version}/libssh-${version}.tar.xz";
22     hash = "sha256-FLfcxy6R4IFRxYuYGntXCrJmP2MOfSg3ZF1anGEsG3k=";
23   };
25   outputs = [ "out" "dev" ];
27   postPatch = ''
28     # Fix headers to use libsodium instead of NaCl
29     sed -i 's,nacl/,sodium/,g' ./include/libssh/curve25519.h src/curve25519.c
30   '';
32   # Don’t build examples, which are not installed and require additional dependencies not
33   # included in `buildInputs` such as libX11.
34   cmakeFlags = [ "-DWITH_EXAMPLES=OFF" ];
36   buildInputs = [ zlib openssl libsodium ];
38   nativeBuildInputs = [ cmake pkg-config ];
40   postFixup = ''
41     substituteInPlace $dev/lib/cmake/libssh/libssh-config.cmake \
42       --replace-fail "set(_IMPORT_PREFIX \"$out\")" "set(_IMPORT_PREFIX \"$dev\")"
43   '';
45   passthru.tests = {
46     inherit ffmpeg sshping wireshark;
47   };
49   meta = with lib; {
50     description = "SSH client library";
51     homepage = "https://libssh.org";
52     license = licenses.lgpl2Plus;
53     maintainers = with maintainers; [ sander ];
54     platforms = platforms.all;
55   };