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