1{
2 stdenv,
3 fetchurl,
4 lib,
5}:
6
7{ version, src, ... }:
8
9let
10 artifacts =
11 lib.mapAttrs
12 (
13 version: sha512:
14 fetchurl {
15 url = "https://storage.googleapis.com/simon-public-euw3/assets/sqlcipher/${version}.c";
16 inherit sha512;
17 }
18 )
19 {
20 v4_5_7 = "11bb454d761b994f7e44f35dabd3fc8ac3b40499d6fdc29d58a38fb9b4dcdd6eb14ff3978ceb7c6f3bd5eee4a5abeec5f0453b944268f9aaf942b0366df1e73d";
21 v4_5_6 = "939ae692239adc0581211a37ed9ffa8b37c8f771c830977ecb06dc6accc4c3db767ce6abeaf91133815e2ae837785affa92f4c95b2e68cb6d563bd761f3e0cb1";
22 };
23in
24stdenv.mkDerivation rec {
25 pname = "sqlcipher_flutter_libs";
26 inherit version src;
27 inherit (src) passthru;
28
29 installPhase = ''
30 runHook preInstall
31
32 cp -r "$src" "$out"
33 _replace() {
34 URL="https://storage.googleapis.com/simon-public-euw3/assets/sqlcipher/v$1.c"
35 # --replace-fail messes with the file if it fails (is empty afterwards) so we do this instead
36 if cat "$out/linux/CMakeLists.txt" | grep "$URL" >/dev/null 2>/dev/null; then
37 substituteInPlace "$out/linux/CMakeLists.txt" --replace "$URL" "file://$2"
38 else
39 return 2
40 fi
41 }
42 _replace "4_5_7" "${artifacts.v4_5_7}" || \
43 _replace "4_5_6" "${artifacts.v4_5_6}" || \
44 (echo "unknown version of sqlcipher, please add to pkgs/development/compilers/dart/package-source-builders/sqlcipher_flutter_libs" && cat linux/CMakeLists.txt | grep "https://storage.*" -o && exit 2)
45
46 runHook postInstall
47 '';
48
49 meta.sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
50}