From 00ddb07a9d0a9376d92069a2f9f5b48801330a5c Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Fri, 17 Apr 2026 10:08:30 +0200 Subject: [PATCH] libsignal-ffi: build shared library on non-static stdenv --- pkgs/by-name/li/libsignal-ffi/package.nix | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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";