Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 fetchFromGitLab, 5 fetchpatch, 6 gitUpdater, 7 testers, 8 boost, 9 cmake, 10 doxygen, 11 gtest, 12 leveldb, 13 lomiri, 14 pkg-config, 15 python3, 16 validatePkgConfig, 17}: 18 19stdenv.mkDerivation (finalAttrs: { 20 pname = "persistent-cache-cpp"; 21 version = "1.0.7"; 22 23 src = fetchFromGitLab { 24 owner = "ubports"; 25 repo = "development/core/lib-cpp/persistent-cache-cpp"; 26 rev = finalAttrs.version; 27 hash = "sha256-bOABrRSy5Mzeaqoc5ujcGXyBAaCJLv/488M7fkr0npE="; 28 }; 29 30 outputs = [ 31 "out" 32 "dev" 33 "doc" 34 ]; 35 36 patches = [ 37 # PersistentStringCacheImpl.exceptions test fails on LLVM's libcxx, it depends on std::system_error producing a very specific exception text 38 # Expects "Unknown error 666", gets "unspecified generic_category error" 39 # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/14 merged & in release 40 (fetchpatch { 41 name = "0001-persistent-cache-cpp-persistent_string_cache_impl_test-libcxx-fix.patch"; 42 url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/a696dbd3093b8333f9ee1f0cad846b2256c729c5.patch"; 43 hash = "sha256-SJxdXeM7W+WKEmiLTwnQYAM7YmPayEk6vPb46y4thv4="; 44 }) 45 46 # Enable usage of BUILD_TESTING to opting out of tests 47 # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/15 merged & in release 48 (fetchpatch { 49 name = "0002-persistent-cache-cpp-Enable-opting-out-of-tests.patch"; 50 url = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/commit/1fb06d28c16325e90046e93662c0f5fd16c29b4a.patch"; 51 hash = "sha256-2/6EYBh71S4dzqWEde+3dLOGp015fN6IifAj1bI1XAI="; 52 }) 53 ]; 54 55 postPatch = '' 56 # GTest needs C++17 57 # Remove when https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/merge_requests/19 merged & in release 58 substituteInPlace CMakeLists.txt \ 59 --replace-fail 'std=c++14' 'std=c++17' 60 61 # Wrong concatenation 62 substituteInPlace data/libpersistent-cache-cpp.pc.in \ 63 --replace "\''${prefix}/@CMAKE_INSTALL_LIBDIR@" "\''${prefix}/lib" 64 65 # Runs in parallel to other tests, limit to 1 thread 66 substituteInPlace tests/headers/compile_headers.py \ 67 --replace 'multiprocessing.cpu_count()' '1' 68 69 sed '1i#include <iomanip>' \ 70 -i tests/core/persistent_string_cache/speed_test.cpp 71 '' 72 + lib.optionalString finalAttrs.finalPackage.doCheck '' 73 patchShebangs tests/{headers,whitespace}/*.py 74 ''; 75 76 nativeBuildInputs = [ 77 cmake 78 doxygen 79 pkg-config 80 validatePkgConfig 81 ]; 82 83 buildInputs = [ 84 boost 85 lomiri.cmake-extras 86 leveldb 87 ]; 88 89 nativeCheckInputs = [ 90 python3 91 ]; 92 93 checkInputs = [ 94 gtest 95 ]; 96 97 cmakeFlags = [ 98 # error: 'old_version' may be used uninitialized 99 (lib.cmakeBool "Werror" false) 100 # Defaults to static if not set 101 (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) 102 ]; 103 104 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; 105 106 passthru = { 107 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 108 updateScript = gitUpdater { }; 109 }; 110 111 meta = with lib; { 112 description = "Cache of key-value pairs with persistent storage for C++ 11"; 113 longDescription = '' 114 A persistent cache for arbitrary (possibly large amount of data, such as 115 image files) that is fast, scalable, and crash-proof. 116 ''; 117 homepage = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp"; 118 changelog = "https://gitlab.com/ubports/development/core/lib-cpp/persistent-cache-cpp/-/blob/${finalAttrs.version}/ChangeLog"; 119 license = licenses.lgpl3Only; 120 teams = [ teams.lomiri ]; 121 platforms = platforms.unix; 122 pkgConfigModules = [ 123 "libpersistent-cache-cpp" 124 ]; 125 }; 126})