1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 testers,
7
8 static ? stdenv.hostPlatform.isStatic,
9
10 lz4,
11 zlib-ng,
12 zstd,
13}:
14
15stdenv.mkDerivation (finalAttrs: {
16 pname = "c-blosc2";
17 version = "2.19.1";
18
19 src = fetchFromGitHub {
20 owner = "Blosc";
21 repo = "c-blosc2";
22 rev = "v${finalAttrs.version}";
23 sha256 = "sha256-t+zh89VFVnqYzxqZh13hS6iieSqbG+DTPzI4aXwY8os=";
24 };
25
26 # https://github.com/NixOS/nixpkgs/issues/144170
27 postPatch = ''
28 sed -i -E \
29 -e '/^libdir[=]/clibdir=@CMAKE_INSTALL_FULL_LIBDIR@' \
30 -e '/^includedir[=]/cincludedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@' \
31 blosc2.pc.in
32 '';
33
34 nativeBuildInputs = [ cmake ];
35
36 propagatedBuildInputs = [
37 lz4
38 zlib-ng
39 zstd
40 ];
41
42 cmakeFlags = [
43 "-DBUILD_STATIC=${if static then "ON" else "OFF"}"
44 "-DBUILD_SHARED=${if static then "OFF" else "ON"}"
45
46 "-DPREFER_EXTERNAL_LZ4=ON"
47 "-DPREFER_EXTERNAL_ZLIB=ON"
48 "-DPREFER_EXTERNAL_ZSTD=ON"
49
50 "-DBUILD_EXAMPLES=OFF"
51 "-DBUILD_BENCHMARKS=OFF"
52 "-DBUILD_TESTS=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}"
53 ];
54
55 doCheck = !static;
56 # possibly https://github.com/Blosc/c-blosc2/issues/432
57 enableParallelChecking = false;
58
59 passthru.tests = {
60 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
61 cmake-config = testers.hasCmakeConfigModules {
62 moduleNames = [ "Blosc2" ];
63 package = finalAttrs.finalPackage;
64 };
65 };
66
67 meta = with lib; {
68 description = "Fast, compressed, persistent binary data store library for C";
69 homepage = "https://www.blosc.org";
70 changelog = "https://github.com/Blosc/c-blosc2/releases/tag/v${finalAttrs.version}";
71 pkgConfigModules = [ "blosc2" ];
72 license = licenses.bsd3;
73 platforms = platforms.all;
74 maintainers = with maintainers; [ ris ];
75 };
76})