{
  lib,
  stdenv,
  fetchurl,

  at-spi2-atk,
  autoPatchelfHook,
  cairo,
  cups,
  dbus,
  fontconfig,
  freetype,
  gdk-pixbuf,
  glib,
  gtk3,
  libGL,
  libdrm,
  libxcb-cursor,
  libxkbcommon,
  makeWrapper,
  pango,
  wayland,
  xorg,
  zlib,
}:

stdenv.mkDerivation rec {
  pname = "openmv-ide";
  version = "4.8.9";

  src = fetchurl {
    url = "https://github.com/openmv/openmv-ide/releases/download/v${version}/openmv-ide-linux-x86_64-${version}.tar.gz";
    hash = "sha256-D0Uunb6IIX8gkirZIISjjhvrrCsR5bgRBcXidtjN/n0=";
  };

  nativeBuildInputs = [
    autoPatchelfHook
    makeWrapper
  ];

  buildInputs = [
    at-spi2-atk
    cairo
    cups
    dbus.lib
    fontconfig
    freetype
    gdk-pixbuf
    glib
    gtk3
    libGL
    libdrm
    libxcb-cursor
    libxkbcommon
    pango
    stdenv.cc.cc.lib
    wayland
    xorg.libX11
    xorg.libxcb
    xorg.xcbutil
    xorg.xcbutilimage
    xorg.xcbutilkeysyms
    xorg.xcbutilrenderutil
    xorg.xcbutilwm
    zlib
  ];

  autoPatchelfIgnoreMissingDeps = [
    "libQt6Designer.so.6"
    "libQt6Labs*.so.6"
    "libQt6OpenGLWidgets.so.6"
    "libQt6Qml*.so.6"
    "libQt6Quick*.so.6"
    "libQt6ShaderTools.so.6"
    "libgssapi_krb5.so.2"
    "libicudata.so.56"
    "libicui18n.so.56"
    "libicuuc.so.56"
    "libmysqlclient.so.21"
    "libodbc.so.2"
    "libpq.so.5"
  ];

  dontAutoPatchelf = true;
  dontBuild = true;
  dontConfigure = true;
  dontStrip = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/share/openmv-ide
    cp -r bin lib share $out/share/openmv-ide/

    chmod -R u+w $out/share/openmv-ide/

    mkdir -p $out/share/applications
    cp share/applications/io.openmv.openmvide.desktop $out/share/applications/

    mkdir -p $out/share/icons
    cp -r share/icons/hicolor $out/share/icons/

    substituteInPlace $out/share/applications/io.openmv.openmvide.desktop \
      --replace "Exec=openmvide" "Exec=$out/bin/openmvide"

    mkdir -p $out/bin
    makeWrapper $out/share/openmv-ide/bin/openmvide $out/bin/openmvide \
      --prefix LD_LIBRARY_PATH : "$out/share/openmv-ide/lib:$out/share/openmv-ide/lib/qtcreator:$out/share/openmv-ide/lib/Qt/lib" \
      --add-flags "-user-library-path \"\$LD_LIBRARY_PATH\""

    runHook postInstall
  '';

  postFixup = ''
    addAutoPatchelfSearchPath $out/share/openmv-ide/lib/Qt/lib
    addAutoPatchelfSearchPath $out/share/openmv-ide/lib/qtcreator

    # skip embedded third-party toolchains and tools under share/
    autoPatchelf -- \
      $out/share/openmv-ide/bin \
      $out/share/openmv-ide/lib
  '';

  meta = {
    description = "QtCreator based IDE for the OpenMV Cam";
    homepage = "https://openmv.io/";
    license = lib.licenses.gpl3Plus;
    mainProgram = "openmvide";
    platforms = [ "x86_64-linux" ];
    sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
  };
}
