From 731f1c7f86c9ae8f07c5e655b4c25a2f7c918fbd Mon Sep 17 00:00:00 2001 From: Liam Murphy Date: Thu, 4 Jul 2024 14:35:39 +1000 Subject: [PATCH] zed-editor: make $out/bin/zed the CLI, not the main binary The CLI allows opening new files/folders while the app is still running, as well as starting the app in the background without taking up your terminal. This matches the official bundle-linux script: https://github.com/zed-industries/zed/blob/main/script/bundle-linux Before: ```sh $ zed flake.nix zed is already running ``` After: ```sh $ zed flake.nix $ # works! ``` I'm not sure what the current status of this package's Darwin support is; the new code I added should probably be Linux-only, but so should the .desktop file generation which is currently run unconditionally, so I left it as running unconditionally for now. --- pkgs/by-name/ze/zed-editor/package.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ze/zed-editor/package.nix b/pkgs/by-name/ze/zed-editor/package.nix index a9875eccc05f..db67819b3a42 100644 --- a/pkgs/by-name/ze/zed-editor/package.nix +++ b/pkgs/by-name/ze/zed-editor/package.nix @@ -113,6 +113,10 @@ rustPlatform.buildRustPackage rec { ] ); + cargoBuildFlags = [ + "--package=zed" + "--package=cli" + ]; buildFeatures = [ "gpui/runtime_shaders" ]; env = { @@ -129,8 +133,8 @@ rustPlatform.buildRustPackage rec { gpu-lib = if withGLES then libglvnd else vulkan-loader; postFixup = lib.optionalString stdenv.isLinux '' - patchelf --add-rpath ${gpu-lib}/lib $out/bin/* - patchelf --add-rpath ${wayland}/lib $out/bin/* + patchelf --add-rpath ${gpu-lib}/lib $out/libexec/* + patchelf --add-rpath ${wayland}/lib $out/libexec/* ''; checkFlags = lib.optionals stdenv.hostPlatform.isLinux [ @@ -138,7 +142,13 @@ rustPlatform.buildRustPackage rec { "--skip=test_open_paths_action" ]; - postInstall = '' + installPhase = '' + 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/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 @@ -151,6 +161,8 @@ rustPlatform.buildRustPackage rec { mkdir -p "$out/share/applications" ${lib.getExe envsubst} < "crates/zed/resources/zed.desktop.in" > "$out/share/applications/zed.desktop" ) + + runHook postInstall ''; passthru.updateScript = nix-update-script {