@@ -218,68 +218,65 @@ rustPlatform.buildRustPackage rec {
218218 ] ;
219219
220220 installPhase =
221- if stdenv . hostPlatform . isDarwin then
222- ''
223- runHook preInstall
224-
225- # cargo-bundle expects the binary in target/release
226- mv target/${ stdenv . hostPlatform . rust . cargoShortTarget } /release/zed target/release/zed
227-
228- pushd crates/zed
229-
230- # Note that this is GNU sed, while Zed's bundle-mac uses BSD sed
231- sed -i "s/package.metadata.bundle-stable/package.metadata.bundle/" Cargo.toml
232- export CARGO_BUNDLE_SKIP_BUILD=true
233- app_path=$(cargo bundle --release | xargs)
234-
235- # We're not using Zed's fork of cargo-bundle, so we must manually append their plist extensions
236- # Remove closing tags from Info.plist (last two lines)
237- head -n -2 $app_path/Contents/Info.plist > Info.plist
238- # Append extensions
239- cat resources/info/*.plist >> Info.plist
240- # Add closing tags
241- printf "</dict>\n</plist>\n" >> Info.plist
242- mv Info.plist $app_path/Contents/Info.plist
243-
244- popd
245-
246- mkdir -p $out/Applications $out/bin
247- # Zed expects git next to its own binary
248- ln -s ${ git } /bin/git $app_path/Contents/MacOS/git
249- mv target/${ stdenv . hostPlatform . rust . cargoShortTarget } /release/cli $app_path/Contents/MacOS/cli
250- mv $app_path $out/Applications/
251-
252- # Physical location of the CLI must be inside the app bundle as this is used
253- # to determine which app to start
254- ln -s $out/Applications/Zed.app/Contents/MacOS/cli $out/bin/zeditor
255-
256- runHook postInstall
257- ''
258- else
259- ''
260- runHook preInstall
261-
262- mkdir -p $out/bin $out/libexec
263- cp target/${ stdenv . hostPlatform . rust . cargoShortTarget } /release/zed $out/libexec/zed-editor
264- cp target/${ stdenv . hostPlatform . rust . cargoShortTarget } /release/cli $out/bin/zeditor
265-
266- install -D ${ src } /crates/zed/resources/[email protected] $out/share/icons/hicolor/1024x1024@2x/apps/zed.png 267- install -D ${ src } /crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png
268-
269- # extracted from https://github.com/zed-industries/zed/blob/v0.141.2/script/bundle-linux (envsubst)
270- # and https://github.com/zed-industries/zed/blob/v0.141.2/script/install.sh (final desktop file name)
271- (
272- export DO_STARTUP_NOTIFY="true"
273- export APP_CLI="zeditor"
274- export APP_ICON="zed"
275- export APP_NAME="Zed"
276- export APP_ARGS="%U"
277- mkdir -p "$out/share/applications"
278- ${ lib . getExe envsubst } < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
279- )
280-
281- runHook postInstall
282- '' ;
221+ ''
222+ runHook preInstall
223+
224+ release_target="target/${ stdenv . hostPlatform . rust . cargoShortTarget } /release"
225+ ''
226+ + lib . optionalString stdenv . hostPlatform . isDarwin ''
227+ # cargo-bundle expects the binary in target/release
228+ mv $release_target/zed target/release/zed
229+
230+ pushd crates/zed
231+
232+ # Note that this is GNU sed, while Zed's bundle-mac uses BSD sed
233+ sed -i "s/package.metadata.bundle-stable/package.metadata.bundle/" Cargo.toml
234+ export CARGO_BUNDLE_SKIP_BUILD=true
235+ app_path=$(cargo bundle --release | xargs)
236+
237+ # We're not using Zed's fork of cargo-bundle, so we must manually append their plist extensions
238+ # Remove closing tags from Info.plist (last two lines)
239+ head -n -2 $app_path/Contents/Info.plist > Info.plist
240+ # Append extensions
241+ cat resources/info/*.plist >> Info.plist
242+ # Add closing tags
243+ printf "</dict>\n</plist>\n" >> Info.plist
244+ mv Info.plist $app_path/Contents/Info.plist
245+
246+ popd
247+
248+ mkdir -p $out/Applications $out/bin
249+ # Zed expects git next to its own binary
250+ ln -s ${ lib . getExe git } $app_path/Contents/MacOS/git
251+ mv $release_target/cli $app_path/Contents/MacOS/cli
252+ mv $app_path $out/Applications/
253+
254+ # Physical location of the CLI must be inside the app bundle as this is used
255+ # to determine which app to start
256+ ln -s $out/Applications/Zed.app/Contents/MacOS/cli $out/bin/zeditor
257+ ''
258+ + lib . optionalString stdenv . hostPlatform . isLinux ''
259+ install -Dm755 $release_target/zed $out/libexec/zed-editor
260+ install -Dm755 $release_target/cli $out/bin/zeditor
261+
262+ install -Dm644 ${ src } /crates/zed/resources/[email protected] $out/share/icons/hicolor/1024x1024@2x/apps/zed.png 263+ install -Dm644 ${ src } /crates/zed/resources/app-icon.png $out/share/icons/hicolor/512x512/apps/zed.png
264+
265+ # extracted from https://github.com/zed-industries/zed/blob/v0.141.2/script/bundle-linux (envsubst)
266+ # and https://github.com/zed-industries/zed/blob/v0.141.2/script/install.sh (final desktop file name)
267+ (
268+ export DO_STARTUP_NOTIFY="true"
269+ export APP_CLI="zeditor"
270+ export APP_ICON="zed"
271+ export APP_NAME="Zed"
272+ export APP_ARGS="%U"
273+ mkdir -p "$out/share/applications"
274+ ${ lib . getExe envsubst } < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/dev.zed.Zed.desktop"
275+ )
276+ ''
277+ + ''
278+ runHook postInstall
279+ '' ;
283280
284281 nativeInstallCheckInputs = [
285282 versionCheckHook
0 commit comments