1{
2 stdenv,
3 lib,
4 fetchFromGitLab,
5 gitUpdater,
6 testers,
7 boost,
8 cmake,
9 doxygen,
10 gtest,
11 leveldb,
12 lomiri,
13 pkg-config,
14 python3,
15 validatePkgConfig,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "persistent-cache-cpp";
20 version = "1.0.9";
21
22 src = fetchFromGitLab {
23 owner = "ubports";
24 repo = "development/core/lib-cpp/persistent-cache-cpp";
25 rev = finalAttrs.version;
26 hash = "sha256-1ETr4b0HEJIM6a4ObtKWtxn0y4gQy9fzBjE4QhMPGqU=";
27 };
28
29 outputs = [
30 "out"
31 "dev"
32 "doc"
33 ];
34
35 postPatch = ''
36 # Wrong concatenation
37 substituteInPlace data/libpersistent-cache-cpp.pc.in \
38 --replace "\''${prefix}/@CMAKE_INSTALL_LIBDIR@" "\''${prefix}/lib"
39
40 # Runs in parallel to other tests, limit to 1 thread
41 substituteInPlace tests/headers/compile_headers.py \
42 --replace 'multiprocessing.cpu_count()' '1'
43 ''
44 + lib.optionalString finalAttrs.finalPackage.doCheck ''
45 patchShebangs tests/{headers,whitespace}/*.py
46 '';
47
48 nativeBuildInputs = [
49 cmake
50 doxygen
51 pkg-config
52 validatePkgConfig
53 ];
54
55 buildInputs = [
56 boost
57 lomiri.cmake-extras
58 leveldb
59 ];
60
61 nativeCheckInputs = [
62 python3
63 ];
64
65 checkInputs = [
66 gtest
67 ];
68
69 cmakeFlags = [
70 # error: 'old_version' may be used uninitialized
71 (lib.cmakeBool "Werror" false)
72 # Defaults to static if not set
73 (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
74 ];
75
76 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
77
78 passthru = {
79 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
80 updateScript = gitUpdater { };
81 };
82
83 meta = {
84 description = "Cache of key-value pairs with persistent storage for C++ 11";
85 longDescription = ''
86 A persistent cache for arbitrary (possibly large amount of data, such as
87 image files) that is fast, scalable, and crash-proof.
88 '';
89 homepage = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp";
90 changelog = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/blob/${finalAttrs.version}/ChangeLog";
91 license = lib.licenses.lgpl3Only;
92 teams = [ lib.teams.lomiri ];
93 platforms = lib.platforms.unix;
94 pkgConfigModules = [
95 "libpersistent-cache-cpp"
96 ];
97 };
98})