zed-editor: fix license menu

Without the generated licenses file, Zed crashes when triggering the "View Dependency licenses" menu button.
This commit is contained in:
Niklas Korz 2024-09-05 12:20:43 +02:00
parent 93e48559d6
commit b82be0d48c
2 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -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/*