Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zed-editor: shrink darwin closure #369399

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions pkgs/by-name/li/livekit-libwebrtc/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -249,38 +254,35 @@ 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
'';

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" ''
Expand Down
29 changes: 15 additions & 14 deletions pkgs/by-name/ze/zed-editor/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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=";
Expand Down Expand Up @@ -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";
Expand Down
Loading