update/navibeat
1# See https://github.com/NixOS/nixpkgs/blob/4d086f5972639c94a1e805a8aa9c4ddd024bc2c1/pkgs/development/compilers/dart/package-source-builders/sqlite3/default.nix
2{
3 lib,
4 stdenv,
5 fetchurl,
6 writeScript,
7 sqlite,
8}: {
9 version,
10 src,
11 ...
12}: let
13 sqlcipher = let
14 system-alias = {
15 x86_64-linux = "x64.linux";
16 aarch64-linux = "arm64.linux";
17 };
18 in
19 stdenv.mkDerivation {
20 name = "libsqlcipher.so";
21 src = fetchurl {
22 url = "https://github.com/simolus3/sqlite3.dart/releases/download/sqlite3-${version}/libsqlcipher.${
23 system-alias.${stdenv.hostPlatform.system}
24 or (throw "Unsupported system for pub 'sqlite3' ('sqlcipher' dependency)")
25 }.so";
26 sha256 =
27 {
28 _3_5_2-x86_64-linux = "sha256-RdsYQ+ujyR16Ip72A7u2o7uavqtDC72V26pAJAxxOAk=";
29 _3_5_2-aarch64-linux = "sha256-LMKxM9hJXdCGytVuYSro3iYbMuDwDk6fcqvzVYHD7s0=";
30 _3_6_0-x86_64-linux = "sha256-zQkSbJ6FGR8rT1fmwLzSMsdIH1b7HWWbeTdMytIb/vk=";
31 _3_6_0-aarch64-linux = "sha256-MHt26xqayuRRfM6iJTAiC6Pe7ez7FuWiY1ZLaqEwwp8=";
32 }
33 .${
34 "_" + (lib.replaceStrings ["."] ["_"] version) + "-" + stdenv.hostPlatform.system
35 }
36 or (throw "Unsupported version of pub 'sqlite3' ('sqlcipher' dependency '${version}')");
37 };
38 unpackPhase = ":";
39 installPhase = "mkdir -p $out/lib && cp $src $out/lib/libsqlcipher.so";
40 };
41in
42 stdenv.mkDerivation (finalAttrs: {
43 pname = "sqlite3";
44 inherit version src;
45 inherit (src) passthru;
46
47 setupHook = writeScript "${finalAttrs.pname}-setup-hook" ''
48 sqliteFixupHook() {
49 runtimeDependencies+=('${lib.getLib sqlite}')
50 runtimeDependencies+=('${lib.getLib sqlcipher}')
51 }
52
53 preFixupHooks+=(sqliteFixupHook)
54 '';
55
56 postPatch = ''
57 substituteInPlace lib/src/hook/compile/description.dart \
58 --replace-fail "return fromGitHub(LibraryType.sqlite3);" "return LookupSystem('sqlite3');"
59 substituteInPlace lib/src/hook/compile/description.dart \
60 --replace-fail "return fromGitHub(LibraryType.sqlcipher);" "return LookupSystem('sqlcipher');"
61 '';
62
63 installPhase = ''
64 runHook preInstall
65
66 cp --recursive . "$out"
67
68 runHook postInstall
69 '';
70 })