zed-editor: shrink darwin closure (#369399)

This commit is contained in:
Gaétan Lepage 2024-12-31 09:22:29 +01:00 committed by GitHub
commit 8da05cf315
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 29 deletions

View File

@ -147,6 +147,11 @@ stdenv.mkDerivation {
substituteInPlace build/toolchain/apple/toolchain.gni --replace-fail "/bin/cp -Rc" "cp -a"
'';
outputs = [
"dev"
"out"
];
nativeBuildInputs =
(builtins.concatLists (
lib.mapAttrsToList (
@ -249,24 +254,24 @@ stdenv.mkDerivation {
''
runHook preInstall
mkdir -p $out/{lib,include}
cp obj/webrtc.ninja $out/
cp args.gn $out/
cp LICENSE.md $out/
mkdir -p $out/lib
mkdir -p $dev/include
install -m0644 obj/webrtc.ninja args.gn LICENSE.md $dev
pushd ../..
find . -name "*.h" -print | cpio -pd $dev/include
popd
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
cp libwebrtc.so $out/lib/
cp libthird_party_boringssl.so $out/lib/
install -m0644 libwebrtc.so libthird_party_boringssl.so $out/lib
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Library/Frameworks
cp -r WebRTC.framework $out/Library/Frameworks
cp libwebrtc.dylib $out/lib
cp libthird_party_boringssl.dylib $out/lib/
install -m0644 WebRTC.framework/Versions/A/WebRTC $out/lib/libwebrtc.dylib
install -m0644 libthird_party_boringssl.dylib $out/lib
''
+ ''
cd ../..
find . -name "*.h" -print | cpio -pd $out/include
ln -s $out/lib $dev/lib
runHook postInstall
'';
@ -274,13 +279,10 @@ stdenv.mkDerivation {
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
boringssl="$out/lib/libthird_party_boringssl.dylib"
webrtc="$out/lib/libwebrtc.dylib"
framework="$out/Library/Frameworks/WebRTC.framework/Versions/A/WebRTC"
install_name_tool -id "$boringssl" "$boringssl"
install_name_tool -id "$webrtc" "$webrtc"
install_name_tool -change @rpath/libthird_party_boringssl.dylib "$boringssl" "$webrtc"
install_name_tool -id "$framework" "$framework"
install_name_tool -change @rpath/libthird_party_boringssl.dylib "$boringssl" "$framework"
'';
passthru.updateScript = writeShellScript "update-livekit-libwebrtc" ''

View File

@ -112,20 +112,11 @@ rustPlatform.buildRustPackage rec {
"script/patches/use-cross-platform-livekit.patch"
];
postPatch =
lib.optionalString stdenv.hostPlatform.isLinux ''
# Dynamically link WebRTC instead of static
substituteInPlace ../${pname}-${version}-vendor/webrtc-sys-*/build.rs \
--replace-fail "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc"
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# On Darwin, linking against the dylib results in Rust linker errors, while
# linking against the framework works fine.
substituteInPlace ../${pname}-${version}-vendor/webrtc-sys-*/build.rs \
--replace-fail "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=framework=webrtc" \
--replace-fail 'println!("cargo:rustc-link-search=native={}", webrtc_lib.to_str().unwrap());' \
'println!("cargo:rustc-link-search=framework={}/Library/Frameworks", webrtc_dir.to_str().unwrap());'
'';
# Dynamically link WebRTC instead of static
postPatch = ''
substituteInPlace ../${pname}-${version}-vendor/webrtc-sys-*/build.rs \
--replace-fail "cargo:rustc-link-lib=static=webrtc" "cargo:rustc-link-lib=dylib=webrtc"
'';
useFetchCargoVendor = true;
cargoHash = "sha256-J5vJ/KV94a+9AqGbNZx6sCzWflOZsyUj3NcqnfaexGE=";
@ -297,6 +288,16 @@ rustPlatform.buildRustPackage rec {
versionCheckProgramArg = [ "--version" ];
doInstallCheck = true;
# The darwin Applications directory is not stripped by default, see
# https://github.com/NixOS/nixpkgs/issues/367169
# This setting is not platform-guarded as it doesn't do any harm on Linux,
# where this directory simply does not exist.
stripDebugList = [
"bin"
"libexec"
"Applications"
];
passthru = {
updateScript = gitUpdater {
rev-prefix = "v";