1{
2 lib,
3 stdenv,
4 fetchzip,
5 replaceVars,
6}:
7
8{ version, src, ... }:
9
10let
11 selectSystem =
12 attrs:
13 attrs.${stdenv.hostPlatform.system}
14 or (throw "objectbox_flutter_libs: ${stdenv.hostPlatform.system} is not supported");
15
16 arch = selectSystem {
17 x86_64-linux = "x64";
18 aarch64-linux = "aarch64";
19 };
20
21 objectbox-sync = fetchzip {
22 url = "https://github.com/objectbox/objectbox-c/releases/download/v4.0.2/objectbox-sync-linux-${arch}.tar.gz";
23 hash = selectSystem {
24 x86_64-linux = "sha256-VXTuCYg0ZItK+lAs7xkNlxO0rUPnbRZOP5RAXbcRyjM=";
25 aarch64-linux = "sha256-kNlrBRR/qDEhdU34f4eDQLgYkYAIfFC8/of4rgL+m6k=";
26 };
27 stripRoot = false;
28 };
29in
30stdenv.mkDerivation {
31 pname = "objectbox_flutter_libs";
32 inherit version src;
33 inherit (src) passthru;
34
35 patches = [
36 (replaceVars ./CMakeLists.patch {
37 OBJECTBOX_SHARED_LIBRARY = "${objectbox-sync}/lib/libobjectbox.so";
38 })
39 ];
40
41 installPhase = ''
42 runHook preInstall
43
44 cp -r . $out
45
46 runHook postInstall
47 '';
48
49 meta.sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
50}