signal-desktop.webrtc: fix cross compilation

all the new flags here were copied from nixpkgs' chromium package,
at pkgs/applications/networking/browsers/chromium/common.nix.
This commit is contained in:
Colin
2025-09-12 04:43:03 +00:00
parent 6888fc783e
commit c514f72fb9
+37 -1
View File
@@ -1,6 +1,7 @@
{
stdenv,
lib,
buildPackages,
ninja,
gn,
python3,
@@ -13,6 +14,24 @@
rustc,
}:
let
chromiumRosettaStone = {
cpu =
platform:
let
name = platform.parsed.cpu.name;
in
(
{
"x86_64" = "x64";
"i686" = "x86";
"arm" = "arm";
"aarch64" = "arm64";
}
.${name} or (throw "no chromium Rosetta Stone entry for cpu: ${name}")
);
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "signal-webrtc";
version = finalAttrs.gclientDeps."src".path.rev;
@@ -59,7 +78,11 @@ stdenv.mkDerivation (finalAttrs: {
'';
gnFlags = [
# webrtc uses chromium's `src/build/BUILDCONFIG.gn`. many of these flags
# are copied from pkgs/applications/networking/browsers/chromium/common.nix.
''target_os="linux"''
''target_cpu="${chromiumRosettaStone.cpu stdenv.hostPlatform}"''
''pkg_config="${stdenv.cc.targetPrefix}pkg-config"''
"use_sysroot=false"
"is_clang=false"
"treat_warnings_as_errors=false"
@@ -78,7 +101,20 @@ stdenv.mkDerivation (finalAttrs: {
"rtc_include_tests=false"
"rtc_enable_protobuf=false"
''rust_sysroot_absolute="${rustc}"''
''rust_sysroot_absolute="${buildPackages.rustc}"''
# Build using the system toolchain (for Linux distributions):
#
# What you would expect to be called "target_toolchain" is
# actually called either "default_toolchain" or "custom_toolchain",
# depending on which part of the codebase you are in; see:
# https://chromium.googlesource.com/chromium/src/build/+/3c4595444cc6d514600414e468db432e0f05b40f/config/BUILDCONFIG.gn#17
''custom_toolchain="//build/toolchain/linux/unbundle:default"''
''host_toolchain="//build/toolchain/linux/unbundle:default"''
]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
''host_toolchain="//build/toolchain/linux/unbundle:host"''
''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:host"''
];
ninjaFlags = [ "webrtc" ];