zed-editor: add remote_server (#370017)

This commit is contained in:
Gaétan Lepage
2025-01-17 16:25:14 +01:00
committed by GitHub
+64 -54
View File
@@ -39,8 +39,10 @@
libX11,
libXext,
livekit-libwebrtc,
testers,
withGLES ? false,
buildRemoteServer ? true,
}:
assert withGLES -> stdenv.hostPlatform.isLinux;
@@ -95,6 +97,8 @@ rustPlatform.buildRustPackage rec {
pname = "zed-editor";
version = "0.169.2";
outputs = [ "out" ] ++ lib.optional buildRemoteServer "remote_server";
src = fetchFromGitHub {
owner = "zed-industries";
repo = "zed";
@@ -168,7 +172,7 @@ rustPlatform.buildRustPackage rec {
cargoBuildFlags = [
"--package=zed"
"--package=cli"
];
] ++ lib.optional buildRemoteServer "--package=remote_server";
# Required on darwin because we don't have access to the
# proprietary Metal shader compiler.
@@ -218,68 +222,68 @@ rustPlatform.buildRustPackage rec {
];
installPhase =
if stdenv.hostPlatform.isDarwin then
''
runHook preInstall
''
runHook preInstall
# cargo-bundle expects the binary in target/release
mv target/${stdenv.hostPlatform.rust.cargoShortTarget}/release/zed target/release/zed
release_target="target/${stdenv.hostPlatform.rust.cargoShortTarget}/release"
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# cargo-bundle expects the binary in target/release
mv $release_target/zed target/release/zed
pushd crates/zed
pushd crates/zed
# 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)
# 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)
# 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
# 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
popd
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/
mkdir -p $out/Applications $out/bin
# Zed expects git next to its own binary
ln -s ${lib.getExe git} $app_path/Contents/MacOS/git
mv $release_target/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
# 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
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
install -Dm755 $release_target/zed $out/libexec/zed-editor
install -Dm755 $release_target/cli $out/bin/zeditor
runHook postInstall
''
else
''
runHook preInstall
install -Dm644 ${src}/crates/zed/resources/app-icon@2x.png $out/share/icons/hicolor/1024x1024@2x/apps/zed.png
install -Dm644 ${src}/crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png
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
'';
# 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"
)
''
+ lib.optionalString buildRemoteServer ''
install -Dm755 $release_target/remote_server $remote_server/bin/zed-remote-server-stable-$version
''
+ ''
runHook postInstall
'';
nativeInstallCheckInputs = [
versionCheckHook
@@ -305,6 +309,12 @@ rustPlatform.buildRustPackage rec {
};
fhs = fhs { };
fhsWithPackages = f: fhs { additionalPkgs = f; };
tests = {
remoteServerVersion = testers.testVersion {
package = zed-editor.remote_server;
command = "zed-remote-server-stable-${version} version";
};
};
};
meta = {