1{ lib, stdenv
2, cmake
3, fetchpatch2
4, fetchurl
5, perl
6, zlib
7, groff
8, withBzip2 ? false
9, bzip2
10, withLZMA ? false
11, xz
12, withOpenssl ? false
13, openssl
14, withZstd ? false
15, zstd
16, testers
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "libzip";
21 version = "1.10.1";
22
23 src = fetchurl {
24 url = "https://libzip.org/download/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
25 sha256 = "sha256-lmmuXf46xbOJdTbchGaodMjPLA47H90I11snOIQpk2M=";
26 };
27
28 patches = [
29 # https://github.com/nih-at/libzip/issues/404
30 (fetchpatch2 {
31 name = "Check-for-zstd_TARGET-before-using-it-in-a-regex.patch";
32 url = "https://github.com/nih-at/libzip/commit/c719428916b4d19e838f873b1a177b126a080d61.patch";
33 hash = "sha256-4ksbXEM8kNvs3wtbIaXLEQNSKaxl0es/sIg0EINaTHE=";
34 })
35 ];
36
37 outputs = [ "out" "dev" "man" ];
38
39 nativeBuildInputs = [ cmake perl groff ];
40 propagatedBuildInputs = [ zlib ];
41 buildInputs = lib.optionals withLZMA [ xz ]
42 ++ lib.optionals withBzip2 [ bzip2 ]
43 ++ lib.optionals withOpenssl [ openssl ]
44 ++ lib.optionals withZstd [ zstd ];
45
46 # Don't build the regression tests because they don't build with
47 # pkgsStatic and are not executed anyway.
48 cmakeFlags = [ "-DBUILD_REGRESS=0" ];
49
50 preCheck = ''
51 # regress/runtest is a generated file
52 patchShebangs regress
53 '';
54
55 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
56
57 meta = with lib; {
58 homepage = "https://libzip.org/";
59 description = "A C library for reading, creating and modifying zip archives";
60 license = licenses.bsd3;
61 pkgConfigModules = [ "libzip" ];
62 platforms = platforms.unix;
63 changelog = "https://github.com/nih-at/libzip/blob/v${finalAttrs.version}/NEWS.md";
64 };
65})