diff --git a/pkgs/by-name/li/libsignal-ffi/package.nix b/pkgs/by-name/li/libsignal-ffi/package.nix index 39de36a8fb32..c3c1bf4dbf5e 100644 --- a/pkgs/by-name/li/libsignal-ffi/package.nix +++ b/pkgs/by-name/li/libsignal-ffi/package.nix @@ -6,6 +6,8 @@ xcodebuild, protobuf, boringssl, + + withShared ? !stdenv.hostPlatform.isStatic, }: rustPlatform.buildRustPackage (finalAttrs: { pname = "libsignal-ffi"; @@ -21,11 +23,16 @@ rustPlatform.buildRustPackage (finalAttrs: { hash = "sha256-xffBXvq1ikesIjw6cXfphnTIiyuMiUcY8h0pzSgfD8U="; }; - postPatch = lib.optionalString boringssl.passthru.isShared '' - substituteInPlace $cargoDepsCopy/boring-sys-*/build/main.rs \ - --replace-fail "cargo:rustc-link-lib=static=crypto" "cargo:rustc-link-lib=dylib=crypto" \ - --replace-fail "cargo:rustc-link-lib=static=ssl" "cargo:rustc-link-lib=dylib=ssl" - ''; + postPatch = + lib.optionalString withShared '' + substituteInPlace rust/bridge/ffi/Cargo.toml \ + --replace-fail 'crate-type = ["staticlib"]' 'crate-type = ["cdylib"]' + '' + + lib.optionalString boringssl.passthru.isShared '' + substituteInPlace $cargoDepsCopy/*/boring-sys-*/build/main.rs \ + --replace-fail "cargo:rustc-link-lib=static=crypto" "cargo:rustc-link-lib=dylib=crypto" \ + --replace-fail "cargo:rustc-link-lib=static=ssl" "cargo:rustc-link-lib=dylib=ssl" + ''; nativeBuildInputs = [ protobuf @@ -46,6 +53,11 @@ rustPlatform.buildRustPackage (finalAttrs: { "libsignal-ffi" ]; + postFixup = lib.optionalString (withShared && stdenv.hostPlatform.isDarwin) '' + dylib="$out/lib/libsignal_ffi.dylib" + install_name_tool -id "$dylib" "$dylib" + ''; + meta = { description = "C ABI library which exposes Signal protocol logic"; homepage = "https://github.com/signalapp/libsignal";