{ stdenv, fetchurl, lib, makeWrapper, patchelf, alsa-lib, wayland, libxkbcommon, vulkan-loader, mesa, xkeyboard-config, libXau, libxcb, libX11, libXdmcp, ... }: stdenv.mkDerivation rec { pname = "zeditor"; version = "1.1.5-pre"; src = fetchurl { url = "https://github.com/zed-industries/zed/releases/download/v${version}/zed-linux-x86_64.tar.gz"; sha256 = "sha256-On98WABzkaZGu1MqyA/NIy28wdl3YHHExkxeCelUDlg="; }; nativeBuildInputs = [ makeWrapper patchelf ]; sourceRoot = "."; dontBuild = true; dontConfigure = true; installPhase = '' runHook preInstall mkdir -p $out/bin $out/libexec $out/lib $out/share APP_NAME=zed-preview TARGET_DIR=$APP_NAME.app cp -r $TARGET_DIR/bin/* $out/bin/ cp -r $TARGET_DIR/libexec/* $out/libexec/ cp -r $TARGET_DIR/lib/* $out/lib/ cp -r $TARGET_DIR/share/* $out/share/ cp $TARGET_DIR/licenses.md $out/share/ chmod +x $out/bin/zed chmod +x $out/libexec/zed-editor wrapProgram $out/bin/zed \ --prefix LD_LIBRARY_PATH : ${alsa-lib}/lib:${wayland}/lib:${libxkbcommon}/lib:${vulkan-loader}/lib:${mesa}/lib:${libXau}/lib:${libxcb}/lib:${libX11}/lib:${libXdmcp}/lib \ --set XKB_CONFIG_ROOT ${xkeyboard-config}/share/X11/xkb wrapProgram $out/libexec/zed-editor \ --prefix LD_LIBRARY_PATH : ${alsa-lib}/lib:${wayland}/lib:${libxkbcommon}/lib:${vulkan-loader}/lib:${mesa}/lib \ --set XKB_CONFIG_ROOT ${xkeyboard-config}/share/X11/xkb for lib in $out/lib/*.so*; do if patchelf --print-rpath "$lib" &>/dev/null; then patchelf --set-rpath '$ORIGIN' "$lib" || true fi done patchelf --set-rpath '$ORIGIN/../lib' $out/libexec/.zed-editor-wrapped patchelf --set-rpath '$ORIGIN/../lib' $out/libexec/.zed-editor-wrapped runHook postInstall ''; postInstall = '' substituteInPlace $out/share/applications/dev.zed.Zed-Preview.desktop \ --replace "TryExec=zed" "TryExec=$out/bin/zed" \ --replace "Exec=zed %U" "Exec=$out/bin/zed %U" \ --replace "Exec=zed --new %U" "Exec=$out/bin/zed --new %U" ''; meta = with lib; { description = "A high-performance, multiplayer code editor"; homepage = "https://zed.dev"; platforms = [ "x86_64-linux" ]; license = licenses.mit; maintainers = with maintainers; [ apr ]; }; }