From b82be0d48c4713801a42ec6b68fa1a00c131d5a5 Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Thu, 5 Sep 2024 12:20:43 +0200 Subject: [PATCH 1/2] zed-editor: fix license menu Without the generated licenses file, Zed crashes when triggering the "View Dependency licenses" menu button. --- .../ze/zed-editor/0001-generate-licenses.patch | 17 +++++++++++++++++ pkgs/by-name/ze/zed-editor/package.nix | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 pkgs/by-name/ze/zed-editor/0001-generate-licenses.patch diff --git a/pkgs/by-name/ze/zed-editor/0001-generate-licenses.patch b/pkgs/by-name/ze/zed-editor/0001-generate-licenses.patch new file mode 100644 index 000000000000..4d02d0931d40 --- /dev/null +++ b/pkgs/by-name/ze/zed-editor/0001-generate-licenses.patch @@ -0,0 +1,17 @@ +diff --git a/script/generate-licenses b/script/generate-licenses +index 43b2f5c458..c740a3afa2 100755 +--- a/script/generate-licenses ++++ b/script/generate-licenses +@@ -15,12 +15,6 @@ cat assets/icons/LICENSES >> $OUTPUT_FILE + + echo -e "# ###### CODE LICENSES ######\n" >> $OUTPUT_FILE + +-if ! cargo install --list | grep "cargo-about v$CARGO_ABOUT_VERSION" > /dev/null; then +- echo "Installing cargo-about@$CARGO_ABOUT_VERSION..." +- cargo install "cargo-about@$CARGO_ABOUT_VERSION" +-else +- echo "cargo-about@$CARGO_ABOUT_VERSION is already installed." +-fi + + echo "Generating cargo licenses" + cargo about generate --fail -c script/licenses/zed-licenses.toml script/licenses/template.hbs.md >> $OUTPUT_FILE diff --git a/pkgs/by-name/ze/zed-editor/package.nix b/pkgs/by-name/ze/zed-editor/package.nix index 4b61a77d22a7..a33567fa5b76 100644 --- a/pkgs/by-name/ze/zed-editor/package.nix +++ b/pkgs/by-name/ze/zed-editor/package.nix @@ -27,6 +27,7 @@ vulkan-loader, envsubst, nix-update-script, + cargo-about, withGLES ? false, }: @@ -45,6 +46,12 @@ rustPlatform.buildRustPackage rec { 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 + ]; + cargoLock = { lockFile = ./Cargo.lock; outputHashes = { @@ -73,6 +80,7 @@ rustPlatform.buildRustPackage rec { pkg-config protobuf rustPlatform.bindgenHook + cargo-about ] ++ lib.optionals stdenv.isDarwin [ xcbuild.xcrun ]; buildInputs = @@ -133,6 +141,10 @@ rustPlatform.buildRustPackage rec { RUSTFLAGS = if withGLES then "--cfg gles" else ""; gpu-lib = if withGLES then libglvnd else vulkan-loader; + preBuild = '' + bash script/generate-licenses + ''; + postFixup = lib.optionalString stdenv.isLinux '' patchelf --add-rpath ${gpu-lib}/lib $out/libexec/* patchelf --add-rpath ${wayland}/lib $out/libexec/* From afce61251d28899e33ffaabdabedbbd5bd3b9bcd Mon Sep 17 00:00:00 2001 From: Niklas Korz Date: Thu, 5 Sep 2024 12:20:33 +0200 Subject: [PATCH 2/2] zed-editor: fix `--version` --- pkgs/by-name/ze/zed-editor/package.nix | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/ze/zed-editor/package.nix b/pkgs/by-name/ze/zed-editor/package.nix index a33567fa5b76..f999227661c8 100644 --- a/pkgs/by-name/ze/zed-editor/package.nix +++ b/pkgs/by-name/ze/zed-editor/package.nix @@ -28,6 +28,8 @@ envsubst, nix-update-script, cargo-about, + testers, + zed-editor, withGLES ? false, }: @@ -136,6 +138,8 @@ 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."; + # Used by `zed --version` + RELEASE_VERSION = version; }; RUSTFLAGS = if withGLES then "--cfg gles" else ""; @@ -187,11 +191,17 @@ rustPlatform.buildRustPackage rec { runHook postInstall ''; - passthru.updateScript = nix-update-script { - extraArgs = [ - "--version-regex" - "v(.*)" - ]; + passthru = { + updateScript = nix-update-script { + extraArgs = [ + "--version-regex" + "v(.*)" + ]; + }; + tests.version = testers.testVersion { + inherit version; + package = zed-editor; + }; }; meta = {