{ stdenv, pkgs, fetchurl, lib, unzip, autoPatchelfHook, makeWrapper, ... }:

stdenv.mkDerivation rec {
  pname = "Excite Cymbal Pro";
  version = "latest";
  src = ../../assets/binary-installers/excite_cymbal_pro-v1.0.1.zip;
  nativeBuildInputs = [ makeWrapper unzip autoPatchelfHook ];
  buildInputs = with pkgs; [
    freetype
    fontconfig
    alsa-lib
    pipewire
    curl
    stdenv.cc.cc.lib
    xorg.libICE
    xorg.libSM
    xorg.libX11
    xorg.libXext
    xorg.libXcursor
    xorg.libxkbfile
    zulip.out
    xcb-util-cursor
    libxkbcommon
  ];

  unpackPhase = ''
    unzip $src
  '';

  installPhase = ''
    mkdir -p $out/lib/vst3
    cp -r excite_cymbal_pro/excite_cymbal_PRO.vst3 $out/lib/vst3/
  '';

  postFixup = ''
    for file in \
      $out/lib/vst3/excite_cymbal_PRO.vst3/Contents/x86_64-linux/excite_cymbal_PRO.so
    do
      patchelf --set-rpath "${lib.makeLibraryPath buildInputs}" $file
    done
  '';

  meta = with lib; {
    homepage = "https://www.chair.audio/";
    description = "Excite Cymbal Pro";
    platforms = platforms.linux;
  };
}
