nixpkgs/pkgs/by-name/li/libsignal-ffi/package.nix
2025-06-01 09:27:14 +02:00

56 lines
1.4 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
runCommand,
xcodebuild,
protobuf,
boringssl,
}:
let
# boring-sys expects the static libraries in build/ instead of lib/
boringssl-wrapper = runCommand "boringssl-wrapper" { } ''
mkdir $out
cd $out
ln -s ${boringssl.out}/lib build
ln -s ${boringssl.dev}/include include
'';
in
rustPlatform.buildRustPackage rec {
pname = "libsignal-ffi";
# must match the version used in mautrix-signal
# see https://github.com/mautrix/signal/issues/401
version = "0.72.1";
src = fetchFromGitHub {
fetchSubmodules = true;
owner = "signalapp";
repo = "libsignal";
tag = "v${version}";
hash = "sha256-A8EAHHcBFSD4ZlvFig64g4+eoZQCuqE/qv509hA3I4s=";
};
nativeBuildInputs = [
protobuf
rustPlatform.bindgenHook
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcodebuild ];
env.BORING_BSSL_PATH = "${boringssl-wrapper}";
env.NIX_LDFLAGS = if stdenv.hostPlatform.isDarwin then "-lc++" else "-lstdc++";
useFetchCargoVendor = true;
cargoHash = "sha256-+vJrywIi/RcGGGns42XlN6S63RBil3fB4XByTLsaFVc=";
cargoBuildFlags = [
"-p"
"libsignal-ffi"
];
meta = with lib; {
description = "C ABI library which exposes Signal protocol logic";
homepage = "https://github.com/signalapp/libsignal";
license = licenses.agpl3Plus;
maintainers = with maintainers; [ pentane ];
};
}