signal-desktop: fix cross compilation (#423089)

Colin 026fdbbf db9b720a

Changed files
+42 -4
pkgs
+3 -1
pkgs/by-name/si/signal-desktop/libsignal-node.nix
···
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 = ''
+1 -1
pkgs/by-name/si/signal-desktop/package.nix
···
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}
+1 -1
pkgs/by-name/si/signal-desktop/signal-sqlcipher.nix
···
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
+37 -1
pkgs/by-name/si/signal-desktop/webrtc.nix
···
{
stdenv,
lib,
+
buildPackages,
ninja,
gn,
python3,
···
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;
···
'';
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"
···
"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" ];