2022-02-20 05:27:41 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, cmake
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
|
|
|
, zlib
|
|
|
|
, libssh2
|
|
|
|
, openssl
|
|
|
|
, pcre
|
|
|
|
, http-parser
|
|
|
|
, libiconv
|
|
|
|
, Security
|
2022-07-18 16:21:45 +00:00
|
|
|
, staticBuild ? stdenv.hostPlatform.isStatic
|
2023-03-15 16:39:30 +00:00
|
|
|
# for passthru.tests
|
|
|
|
, libgit2-glib
|
|
|
|
, python3Packages
|
2024-02-29 20:09:43 +00:00
|
|
|
, gitstatus
|
2022-02-20 05:27:41 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libgit2";
|
2024-02-29 20:09:43 +00:00
|
|
|
version = "1.7.2";
|
2023-03-15 16:39:30 +00:00
|
|
|
# also check the following packages for updates: python3Packages.pygit2 and libgit2-glib
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
outputs = ["lib" "dev" "out"];
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libgit2";
|
|
|
|
repo = "libgit2";
|
|
|
|
rev = "v${version}";
|
2024-02-29 20:09:43 +00:00
|
|
|
hash = "sha256-fVPY/byE2/rxmv/bUykcAbmUFMlF3UZogVuTzjOXJUU=";
|
2022-02-20 05:27:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DUSE_HTTP_PARSER=system"
|
|
|
|
"-DUSE_SSH=ON"
|
2022-07-18 16:21:45 +00:00
|
|
|
"-DBUILD_SHARED_LIBS=${if staticBuild then "OFF" else "ON"}"
|
2024-01-02 11:29:13 +00:00
|
|
|
] ++ lib.optionals stdenv.hostPlatform.isWindows [
|
|
|
|
"-DDLLTOOL=${stdenv.cc.bintools.targetPrefix}dlltool"
|
|
|
|
# For ws2_32, refered to by a `*.pc` file
|
|
|
|
"-DCMAKE_LIBRARY_PATH=${stdenv.cc.libc}/lib"
|
2022-02-20 05:27:41 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake python3 pkg-config ];
|
|
|
|
|
|
|
|
buildInputs = [ zlib libssh2 openssl pcre http-parser ]
|
|
|
|
++ lib.optional stdenv.isDarwin Security;
|
|
|
|
|
|
|
|
propagatedBuildInputs = lib.optional (!stdenv.isLinux) libiconv;
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
testArgs=(-v -xonline)
|
|
|
|
|
|
|
|
# slow
|
|
|
|
testArgs+=(-xclone::nonetwork::bad_urls)
|
|
|
|
|
|
|
|
# failed to set permissions on ...: Operation not permitted
|
|
|
|
testArgs+=(-xrepo::init::extended_1)
|
|
|
|
testArgs+=(-xrepo::template::extended_with_template_and_shared_mode)
|
|
|
|
|
|
|
|
(
|
|
|
|
set -x
|
|
|
|
./libgit2_tests ''${testArgs[@]}
|
|
|
|
)
|
|
|
|
'';
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit libgit2-glib;
|
|
|
|
inherit (python3Packages) pygit2;
|
2024-02-29 20:09:43 +00:00
|
|
|
inherit gitstatus;
|
2023-03-15 16:39:30 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
meta = with lib; {
|
2022-02-20 05:27:41 +00:00
|
|
|
description = "Linkable library implementation of Git that you can use in your application";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "git2";
|
2022-02-20 05:27:41 +00:00
|
|
|
homepage = "https://libgit2.org/";
|
2024-06-20 14:57:18 +00:00
|
|
|
license = licenses.gpl2Only;
|
2022-05-18 14:49:53 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2022-02-20 05:27:41 +00:00
|
|
|
};
|
|
|
|
}
|