signal-desktop: fix cross compilation (#423089)

This commit is contained in:
Colin
2025-09-13 08:25:08 +00:00
committed by GitHub
4 changed files with 42 additions and 4 deletions

View File

@@ -70,7 +70,9 @@ rustPlatform.buildRustPackage (finalAttrs: {
substituteInPlace node/build_node_bridge.py \
--replace-fail "dst_base = 'libsignal_client_%s_%s' % (node_os_name, node_arch)" \
"dst_base = '@signalapp+libsignal-client'"
"dst_base = '@signalapp+libsignal-client'" \
--replace-fail "objcopy = shutil.which('%s-linux-gnu-objcopy' % cargo_target.split('-')[0]) or 'objcopy'" \
"objcopy = os.getenv('OBJCOPY', 'objcopy')"
'';
buildPhase = ''

View File

@@ -199,7 +199,7 @@ stdenv.mkDerivation (finalAttrs: {
pnpm run generate
pnpm exec electron-builder \
--dir \
--linux "dir:${stdenv.hostPlatform.node.arch}" \
--config.extraMetadata.environment=$SIGNAL_ENV \
-c.electronDist=electron-dist \
-c.electronVersion=${electron.version}

View File

@@ -47,7 +47,7 @@ stdenv.mkDerivation (finalAttrs: {
runHook preBuild
export npm_config_nodedir=${nodejs}
pnpm run prebuildify
pnpm run prebuildify --strip false --arch "${stdenv.hostPlatform.node.arch}" --platform "${stdenv.hostPlatform.node.platform}"
pnpm run build
runHook postBuild

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" ];