From c5d39000da56342cd1c6c2dcb19a45799ab0260a Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Mon, 18 Nov 2024 11:38:28 +0100 Subject: [PATCH] zed-editor: 0.165.4 -> 0.166.1 --- .../0002-disable-livekit-darwin.patch | 55 ---------------- pkgs/by-name/ze/zed-editor/package.nix | 66 +++++++++++-------- 2 files changed, 40 insertions(+), 81 deletions(-) delete mode 100644 pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch diff --git a/pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch b/pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch deleted file mode 100644 index 2c82a2d49b6882..00000000000000 --- a/pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff --git a/crates/live_kit_client/Cargo.toml b/crates/live_kit_client/Cargo.toml -index e23c63453e..d0142b83d8 100644 ---- a/crates/live_kit_client/Cargo.toml -+++ b/crates/live_kit_client/Cargo.toml -@@ -40,10 +40,10 @@ nanoid = { workspace = true, optional = true} - parking_lot.workspace = true - postage.workspace = true - --[target.'cfg(target_os = "macos")'.dependencies] -+[target.'cfg(target_os = "none")'.dependencies] - core-foundation.workspace = true - --[target.'cfg(all(not(target_os = "macos")))'.dependencies] -+[target.'cfg(all(not(target_os = "none")))'.dependencies] - async-trait = { workspace = true } - collections = { workspace = true } - gpui = { workspace = true } -diff --git a/crates/live_kit_client/build.rs b/crates/live_kit_client/build.rs -index 2fdfd982bf..7272614b87 100644 ---- a/crates/live_kit_client/build.rs -+++ b/crates/live_kit_client/build.rs -@@ -36,7 +36,7 @@ const MACOS_TARGET_VERSION: &str = "10.15.7"; - - fn main() { - if cfg!(all( -- target_os = "macos", -+ target_os = "none", - not(any(test, feature = "test-support", feature = "no-webrtc")), - )) { - let swift_target = get_swift_target(); -diff --git a/crates/live_kit_client/src/live_kit_client.rs b/crates/live_kit_client/src/live_kit_client.rs -index 4820a4eedb..6179e6c55a 100644 ---- a/crates/live_kit_client/src/live_kit_client.rs -+++ b/crates/live_kit_client/src/live_kit_client.rs -@@ -2,16 +2,16 @@ - - use std::sync::Arc; - --#[cfg(all(target_os = "macos", not(any(test, feature = "test-support"))))] -+#[cfg(all(target_os = "none", not(any(test, feature = "test-support"))))] - pub mod prod; - --#[cfg(all(target_os = "macos", not(any(test, feature = "test-support"))))] -+#[cfg(all(target_os = "none", not(any(test, feature = "test-support"))))] - pub use prod::*; - --#[cfg(any(test, feature = "test-support", not(target_os = "macos")))] -+#[cfg(any(test, feature = "test-support", not(target_os = "none")))] - pub mod test; - --#[cfg(any(test, feature = "test-support", not(target_os = "macos")))] -+#[cfg(any(test, feature = "test-support", not(target_os = "none")))] - pub use test::*; - - pub type Sid = String; diff --git a/pkgs/by-name/ze/zed-editor/package.nix b/pkgs/by-name/ze/zed-editor/package.nix index b774a044e2555a..7f04320f1f2735 100644 --- a/pkgs/by-name/ze/zed-editor/package.nix +++ b/pkgs/by-name/ze/zed-editor/package.nix @@ -35,6 +35,10 @@ darwinMinVersionHook, makeWrapper, nodejs_22, + libGL, + libX11, + libXext, + livekit-libwebrtc, withGLES ? false, }: @@ -89,35 +93,42 @@ let in rustPlatform.buildRustPackage rec { pname = "zed-editor"; - version = "0.165.4"; + version = "0.166.1"; src = fetchFromGitHub { owner = "zed-industries"; repo = "zed"; - rev = "refs/tags/v${version}"; - hash = "sha256-g+ZHchlxeNDkxUM306OK3BsjrvO3snF4vcQQZJSIhLc="; + tag = "v${version}"; + hash = "sha256-ss4dz9qPAP6eIYbG3S5QJaSR5zEyEqLBjfacj/eb7AE="; }; - patches = - [ - # Zed uses cargo-install to install cargo-about during the script execution. - # We provide cargo-about ourselves and can skip this step. - # Until https://github.com/zed-industries/zed/issues/19971 is fixed, - # we also skip any crate for which the license cannot be determined. - ./0001-generate-licenses.patch - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # The Swift variant of livekit currently used inside Zed requires - # Swift 6, which is not available in nixpkgs yet: - # https://github.com/NixOS/nixpkgs/issues/343210 - # The Rust variant of livekit for Zed is still pending and there is no - # schedule when it will be finished: - # https://github.com/zed-industries/zed/pull/13343 - ./0002-disable-livekit-darwin.patch - ]; + patches = [ + # Zed uses cargo-install to install cargo-about during the script execution. + # We provide cargo-about ourselves and can skip this step. + # Until https://github.com/zed-industries/zed/issues/19971 is fixed, + # we also skip any crate for which the license cannot be determined. + ./0001-generate-licenses.patch + # See https://github.com/zed-industries/zed/pull/21661#issuecomment-2524161840 + "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());' + ''; useFetchCargoVendor = true; - cargoHash = "sha256-ZNXvuHX9b3T58FUs9TjpfiGYNr9J3IDbz2JE6Vy7Sg0="; + cargoHash = "sha256-HbOdY+6FKGTK5gW2BkWSdciBvTx+oKhCchFvwKEoGNE="; nativeBuildInputs = [ @@ -151,14 +162,16 @@ rustPlatform.buildRustPackage rec { libxkbcommon wayland xorg.libxcb + # required by livekit: + libGL + libX11 + libXext ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_15 - # This will need to be increased to 12.3 once - # https://github.com/zed-industries/zed/pull/13343 - # is merged and released, as ScreenCaptureKit is only available on 12.3 and up: + # ScreenCaptureKit, required by livekit, is only available on 12.3 and up: # https://developer.apple.com/documentation/screencapturekit - (darwinMinVersionHook "10.15") + (darwinMinVersionHook "12.3") ]; cargoBuildFlags = [ @@ -183,6 +196,7 @@ rustPlatform.buildRustPackage rec { ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled."; # Used by `zed --version` RELEASE_VERSION = version; + LK_CUSTOM_WEBRTC = livekit-libwebrtc; }; RUSTFLAGS = if withGLES then "--cfg gles" else ""; @@ -295,7 +309,7 @@ rustPlatform.buildRustPackage rec { meta = { description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter"; homepage = "https://zed.dev"; - changelog = "https://github.com/zed-industries/zed/releases/tag/v${version}"; + changelog = "https://github.com/zed-industries/zed/releases/tag/${src.tag}"; license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ GaetanLepage