1{ 2 lib, 3 rustPlatform, 4 writeText, 5 stdenv, 6}: 7 8{ version, src, ... }: 9 10let 11 rustDep = rustPlatform.buildRustPackage { 12 pname = "flutter_vodozemac-rs"; 13 inherit version src; 14 15 sourceRoot = "${src.name}/rust"; 16 17 cargoHash = 18 { 19 _0_2_2 = "sha256-Iw0AkHVjR1YmPe+C0YYBTDu5FsRk/ZpaRyBilcvqm6M="; 20 } 21 .${"_" + (lib.replaceStrings [ "." ] [ "_" ] version)} or (throw '' 22 Unsupported version of pub 'flutter_vodozemac': '${version}' 23 Please add cargoHash here. If the cargoHash 24 is the same with existing versions, add an alias here. 25 ''); 26 27 passthru.libraryPath = "lib/libvodozemac_bindings_dart.so"; 28 }; 29 30 fakeCargokitCmake = writeText "FakeCargokit.cmake" '' 31 function(apply_cargokit target manifest_dir lib_name any_symbol_name) 32 set("''${target}_cargokit_lib" ${rustDep}/${rustDep.passthru.libraryPath} PARENT_SCOPE) 33 endfunction() 34 ''; 35 36 getLibraryPath = '' 37 String _getLibraryPath() { 38 if (kIsWeb) { 39 return './'; 40 } 41 try { 42 return Platform.resolvedExecutable + '/../lib/libvodozemac_bindings_dart.so'; 43 } catch (_) { 44 return './'; 45 } 46 } 47 ''; 48in 49stdenv.mkDerivation { 50 pname = "flutter_vodozemac"; 51 inherit version src; 52 passthru = src.passthru // { 53 # vodozemac-wasm in fluffychat will make use of it 54 inherit (rustDep) cargoDeps; 55 }; 56 57 installPhase = '' 58 runHook preInstall 59 60 cp -r "$src" "$out" 61 pushd $out 62 chmod +rwx cargokit/cmake/cargokit.cmake 63 cp ${fakeCargokitCmake} cargokit/cmake/cargokit.cmake 64 chmod +rw lib/flutter_vodozemac.dart 65 substituteInPlace lib/flutter_vodozemac.dart \ 66 --replace-warn "libraryPath: './'" "libraryPath: _getLibraryPath()" 67 echo "${getLibraryPath}" >> lib/flutter_vodozemac.dart 68 popd 69 70 runHook postInstall 71 ''; 72}