1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, pkg-config
6, python3
7, zlib
8, libssh2
9, openssl
10, pcre
11, http-parser
12, libiconv
13, Security
14, staticBuild ? stdenv.hostPlatform.isStatic
15# for passthru.tests
16, libgit2-glib
17, python3Packages
18}:
19
20stdenv.mkDerivation rec {
21 pname = "libgit2";
22 version = "1.6.4";
23 # also check the following packages for updates: python3Packages.pygit2 and libgit2-glib
24
25 src = fetchFromGitHub {
26 owner = "libgit2";
27 repo = "libgit2";
28 rev = "v${version}";
29 hash = "sha256-lW3mokVKsbknVj2xsxEbeZH4IdKZ0aIgGutzenS0Eh0=";
30 };
31
32 cmakeFlags = [
33 "-DUSE_HTTP_PARSER=system"
34 "-DUSE_SSH=ON"
35 "-DBUILD_SHARED_LIBS=${if staticBuild then "OFF" else "ON"}"
36 ];
37
38 nativeBuildInputs = [ cmake python3 pkg-config ];
39
40 buildInputs = [ zlib libssh2 openssl pcre http-parser ]
41 ++ lib.optional stdenv.isDarwin Security;
42
43 propagatedBuildInputs = lib.optional (!stdenv.isLinux) libiconv;
44
45 doCheck = false; # hangs. or very expensive?
46
47 passthru.tests = {
48 inherit libgit2-glib;
49 inherit (python3Packages) pygit2;
50 };
51
52 meta = with lib; {
53 description = "Linkable library implementation of Git that you can use in your application";
54 homepage = "https://libgit2.org/";
55 license = licenses.gpl2Plus;
56 platforms = platforms.all;
57 maintainers = with maintainers; [ SuperSandro2000 ];
58 };
59}