mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
zed-editor: fix darwin (#329653)
This commit is contained in:
commit
67d8538ef6
55
pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch
Normal file
55
pkgs/by-name/ze/zed-editor/0002-disable-livekit-darwin.patch
Normal file
@ -0,0 +1,55 @@
|
||||
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;
|
@ -9,7 +9,6 @@
|
||||
perl,
|
||||
pkg-config,
|
||||
protobuf,
|
||||
xcbuild,
|
||||
fontconfig,
|
||||
freetype,
|
||||
libgit2,
|
||||
@ -23,7 +22,6 @@
|
||||
libglvnd,
|
||||
xorg,
|
||||
stdenv,
|
||||
darwin,
|
||||
makeFontsConf,
|
||||
vulkan-loader,
|
||||
envsubst,
|
||||
@ -32,6 +30,10 @@
|
||||
versionCheckHook,
|
||||
zed-editor,
|
||||
buildFHSEnv,
|
||||
cargo-bundle,
|
||||
git,
|
||||
apple-sdk_15,
|
||||
darwinMinVersionHook,
|
||||
|
||||
withGLES ? false,
|
||||
}:
|
||||
@ -93,14 +95,23 @@ rustPlatform.buildRustPackage rec {
|
||||
repo = "zed";
|
||||
rev = "refs/tags/v${version}";
|
||||
hash = "sha256-xtSdlzj1AxhJN4aXLJ+Oy51LX4QduLwcuCfK42kthvE=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Zed uses cargo-install to install cargo-about during the script execution.
|
||||
# We provide cargo-about ourselves and can skip this step.
|
||||
./0001-generate-licenses.patch
|
||||
];
|
||||
patches =
|
||||
[
|
||||
# Zed uses cargo-install to install cargo-about during the script execution.
|
||||
# We provide cargo-about ourselves and can skip this step.
|
||||
./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
|
||||
];
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
@ -132,7 +143,7 @@ rustPlatform.buildRustPackage rec {
|
||||
protobuf
|
||||
rustPlatform.bindgenHook
|
||||
cargo-about
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ xcbuild.xcrun ];
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ cargo-bundle ];
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
@ -153,30 +164,23 @@ rustPlatform.buildRustPackage rec {
|
||||
wayland
|
||||
xorg.libxcb
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isDarwin (
|
||||
with darwin.apple_sdk.frameworks;
|
||||
[
|
||||
AppKit
|
||||
CoreAudio
|
||||
CoreFoundation
|
||||
CoreGraphics
|
||||
CoreMedia
|
||||
CoreServices
|
||||
CoreText
|
||||
Foundation
|
||||
IOKit
|
||||
Metal
|
||||
Security
|
||||
SystemConfiguration
|
||||
VideoToolbox
|
||||
]
|
||||
);
|
||||
++ 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:
|
||||
# https://developer.apple.com/documentation/screencapturekit
|
||||
(darwinMinVersionHook "10.15")
|
||||
];
|
||||
|
||||
cargoBuildFlags = [
|
||||
"--package=zed"
|
||||
"--package=cli"
|
||||
];
|
||||
buildFeatures = [ "gpui/runtime_shaders" ];
|
||||
|
||||
# Required on darwin because we don't have access to the
|
||||
# proprietary Metal shader compiler.
|
||||
buildFeatures = lib.optionals stdenv.hostPlatform.isDarwin [ "gpui/runtime_shaders" ];
|
||||
|
||||
env = {
|
||||
ZSTD_SYS_USE_PKG_CONFIG = true;
|
||||
@ -188,9 +192,12 @@ rustPlatform.buildRustPackage rec {
|
||||
};
|
||||
# Setting this environment variable allows to disable auto-updates
|
||||
# https://zed.dev/docs/development/linux#notes-for-packaging-zed
|
||||
ZED_UPDATE_EXPLANATION = "zed has been installed using nix. Auto-updates have thus been disabled.";
|
||||
ZED_UPDATE_EXPLANATION = "Zed has been installed using Nix. Auto-updates have thus been disabled.";
|
||||
# Used by `zed --version`
|
||||
RELEASE_VERSION = version;
|
||||
# Required until `-isysroot` can be used with libclang in nixpkgs on darwin, otherwise
|
||||
# rust bindgen will not work as expected
|
||||
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-F${apple-sdk_15.sdkroot}/System/Library/Frameworks";
|
||||
};
|
||||
|
||||
RUSTFLAGS = if withGLES then "--cfg gles" else "";
|
||||
@ -209,38 +216,79 @@ rustPlatform.buildRustPackage rec {
|
||||
export HOME=$(mktemp -d);
|
||||
'';
|
||||
|
||||
checkFlags = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
# Fails on certain hosts (including Hydra) for unclear reason
|
||||
"--skip=test_open_paths_action"
|
||||
checkFlags =
|
||||
[
|
||||
# Flaky: unreliably fails on certain hosts (including Hydra)
|
||||
"--skip=zed::tests::test_window_edit_state_restoring_enabled"
|
||||
]
|
||||
++ lib.optionals stdenv.hostPlatform.isLinux [
|
||||
# Fails on certain hosts (including Hydra) for unclear reason
|
||||
"--skip=test_open_paths_action"
|
||||
];
|
||||
|
||||
# Flaky: unreliably fails on certain hosts (including Hydra)
|
||||
"--skip=zed::tests::test_window_edit_state_restoring_enabled"
|
||||
];
|
||||
installPhase =
|
||||
if stdenv.hostPlatform.isDarwin then
|
||||
''
|
||||
runHook preInstall
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
# cargo-bundle expects the binary in target/release
|
||||
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed target/release/zed
|
||||
|
||||
mkdir -p $out/bin $out/libexec
|
||||
cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed $out/libexec/zed-editor
|
||||
cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cli $out/bin/zeditor
|
||||
pushd crates/zed
|
||||
|
||||
install -D ${src}/crates/zed/resources/app-icon@2x.png $out/share/icons/hicolor/1024x1024@2x/apps/zed.png
|
||||
install -D ${src}/crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png
|
||||
# Note that this is GNU sed, while Zed's bundle-mac uses BSD sed
|
||||
sed -i "s/package.metadata.bundle-stable/package.metadata.bundle/" Cargo.toml
|
||||
export CARGO_BUNDLE_SKIP_BUILD=true
|
||||
app_path=$(cargo bundle --release | xargs)
|
||||
|
||||
# extracted from https://github.com/zed-industries/zed/blob/v0.141.2/script/bundle-linux (envsubst)
|
||||
# and https://github.com/zed-industries/zed/blob/v0.141.2/script/install.sh (final desktop file name)
|
||||
(
|
||||
export DO_STARTUP_NOTIFY="true"
|
||||
export APP_CLI="zeditor"
|
||||
export APP_ICON="zed"
|
||||
export APP_NAME="Zed"
|
||||
export APP_ARGS="%U"
|
||||
mkdir -p "$out/share/applications"
|
||||
${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
|
||||
)
|
||||
# We're not using Zed's fork of cargo-bundle, so we must manually append their plist extensions
|
||||
# Remove closing tags from Info.plist (last two lines)
|
||||
head -n -2 $app_path/Contents/Info.plist > Info.plist
|
||||
# Append extensions
|
||||
cat resources/info/*.plist >> Info.plist
|
||||
# Add closing tags
|
||||
printf "</dict>\n</plist>\n" >> Info.plist
|
||||
mv Info.plist $app_path/Contents/Info.plist
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
popd
|
||||
|
||||
mkdir -p $out/Applications $out/bin
|
||||
# Zed expects git next to its own binary
|
||||
ln -s ${git}/bin/git $app_path/Contents/MacOS/git
|
||||
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cli $app_path/Contents/MacOS/cli
|
||||
mv $app_path $out/Applications/
|
||||
|
||||
# Physical location of the CLI must be inside the app bundle as this is used
|
||||
# to determine which app to start
|
||||
ln -s $out/Applications/Zed.app/Contents/MacOS/cli $out/bin/zeditor
|
||||
|
||||
runHook postInstall
|
||||
''
|
||||
else
|
||||
''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin $out/libexec
|
||||
cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed $out/libexec/zed-editor
|
||||
cp target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/cli $out/bin/zeditor
|
||||
|
||||
install -D ${src}/crates/zed/resources/app-icon@2x.png $out/share/icons/hicolor/1024x1024@2x/apps/zed.png
|
||||
install -D ${src}/crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png
|
||||
|
||||
# extracted from https://github.com/zed-industries/zed/blob/v0.141.2/script/bundle-linux (envsubst)
|
||||
# and https://github.com/zed-industries/zed/blob/v0.141.2/script/install.sh (final desktop file name)
|
||||
(
|
||||
export DO_STARTUP_NOTIFY="true"
|
||||
export APP_CLI="zeditor"
|
||||
export APP_ICON="zed"
|
||||
export APP_NAME="Zed"
|
||||
export APP_ARGS="%U"
|
||||
mkdir -p "$out/share/applications"
|
||||
${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
|
||||
)
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
nativeInstallCheckInputs = [
|
||||
versionCheckHook
|
||||
@ -268,8 +316,6 @@ rustPlatform.buildRustPackage rec {
|
||||
niklaskorz
|
||||
];
|
||||
mainProgram = "zeditor";
|
||||
platforms = lib.platforms.all;
|
||||
# Currently broken on darwin: https://github.com/NixOS/nixpkgs/pull/303233#issuecomment-2048650618
|
||||
broken = stdenv.hostPlatform.isDarwin;
|
||||
platforms = lib.platforms.linux ++ lib.platforms.darwin;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user