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
35 lines
898 B
Nix
35 lines
898 B
Nix
{ lib, stdenv, rust-bin, makeRustPlatform, perl, pkg-config, cmake, src }:
|
|
|
|
let
|
|
rustToolchain = rust-bin.fromRustupToolchainFile (src + "/vendor/libchat/rust_toolchain.toml");
|
|
rPlatform = makeRustPlatform {
|
|
cargo = rustToolchain;
|
|
rustc = rustToolchain;
|
|
};
|
|
in rPlatform.buildRustPackage {
|
|
pname = "rust-bundle";
|
|
version = "0.1.0";
|
|
inherit src;
|
|
cargoRoot = "rust-bundle";
|
|
|
|
cargoLock = {
|
|
lockFile = src + "/rust-bundle/Cargo.lock";
|
|
outputHashes = {
|
|
"chat-proto-0.1.0" = "sha256-aCl80VOIkd/GK3gnmRuFoSAvPBfeE/FKCaNlLt5AbUU=";
|
|
};
|
|
};
|
|
|
|
nativeBuildInputs = [ perl pkg-config cmake ];
|
|
doCheck = false;
|
|
|
|
buildAndTestSubdir = "rust-bundle";
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/lib
|
|
find . -name "librust_bundle.a" -path "*/release/*" -exec cp {} $out/lib/ \;
|
|
test -f $out/lib/librust_bundle.a
|
|
runHook postInstall
|
|
'';
|
|
}
|