mirror of
https://github.com/logos-messaging/logos-chat.git
synced 2026-02-28 21:03:06 +00:00
Add rust-bundle, a single staticlib crate that depends on both libchat and rln as rlibs. This ensures rustc links Rust std exactly once, eliminating duplicate symbol errors on all platforms. Nim targets link against liblogos_chat_bundle.a; Nix uses a bundleDrv instead of separate libchat and rln derivations. Reference: https://doc.rust-lang.org/reference/linkage.html#mixed-rust-and-foreign-codebases
37 lines
1.1 KiB
Nix
37 lines
1.1 KiB
Nix
{ rust-bin, makeRustPlatform, perl, pkg-config, cmake }:
|
|
|
|
let
|
|
rustToolchain = rust-bin.fromRustupToolchainFile ../vendor/libchat/rust_toolchain.toml;
|
|
rPlatform = makeRustPlatform {
|
|
cargo = rustToolchain;
|
|
rustc = rustToolchain;
|
|
};
|
|
in rPlatform.buildRustPackage {
|
|
pname = "libchat";
|
|
version = "0.1.0";
|
|
src = ../vendor/libchat;
|
|
|
|
cargoLock = {
|
|
lockFile = ../vendor/libchat/Cargo.lock;
|
|
outputHashes = {
|
|
"chat-proto-0.1.0" = "sha256-aCl80VOIkd/GK3gnmRuFoSAvPBfeE/FKCaNlLt5AbUU=";
|
|
};
|
|
};
|
|
|
|
nativeBuildInputs = [ perl pkg-config cmake ];
|
|
doCheck = false;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/lib
|
|
cp target/*/release/liblibchat.so $out/lib/ 2>/dev/null || true
|
|
cp target/*/release/liblibchat.dylib $out/lib/ 2>/dev/null || true
|
|
cp target/*/release/liblibchat.a $out/lib/ 2>/dev/null || true
|
|
# fallback: non-cross build path
|
|
cp target/release/liblibchat.so $out/lib/ 2>/dev/null || true
|
|
cp target/release/liblibchat.dylib $out/lib/ 2>/dev/null || true
|
|
cp target/release/liblibchat.a $out/lib/ 2>/dev/null || true
|
|
runHook postInstall
|
|
'';
|
|
}
|