{ lib
, fetchzip
, makeDesktopItem
, imagemagick
, buildFHSUserEnv }: let
  name = "ExpressLRS-Configurator";
  pname = "expresslrs-configurator";
  version = "1.6.1";

  dist = fetchzip {
    name = "${pname}-dist";
    url = "https://github.com/ExpressLRS/ExpressLRS-Configurator/releases/download/v${version}/${pname}-${version}.zip";
    stripRoot = false;
    hash = "sha256-m/e8dsOadjk63cwfnnCBbjXzI/ooWZUGRM5n267JmhQ=";
  };

  desktopItem = makeDesktopItem {
    name = pname;
    exec = pname;
    icon = pname;
    comment = "Cross platform configuration & build tool for the ExpressLRS radio link";
    desktopName = "ExpressLRS Configurator";
    genericName = "radio link configuration & build tool";
  };
in buildFHSUserEnv {
  inherit pname version;
  # copied from chromium deps
  targetPkgs = pkgs: (with pkgs; [
    glib fontconfig freetype pango cairo xorg.libX11 xorg.libXi atk nss nspr
    xorg.libXcursor xorg.libXext xorg.libXfixes xorg.libXrender
    xorg.libXScrnSaver xorg.libXcomposite xorg.libxcb
    alsa-lib xorg.libXdamage xorg.libXtst xorg.libXrandr xorg.libxshmfence expat cups
    dbus gdk-pixbuf gcc-unwrapped.lib
    systemd
    libexif pciutils
    liberation_ttf curl util-linux wget
    flac harfbuzz icu libpng libopus snappy speechd
    bzip2 libcap at-spi2-atk at-spi2-core
    libkrb5 libdrm libglvnd mesa coreutils
    libxkbcommon pipewire wayland
    libva gtk3 gtk4
  ]);
  extraInstallCommands = ''
    mkdir -p $out/share
    ${imagemagick}/bin/convert ${dist}/resources/assets/icon.png -resize 128x128 icon-128.png
    install -m 444 -D icon-128.png $out/share/icons/hicolor/128x128/apps/${pname}.png
    cp -r ${desktopItem}/share/applications $out/share/
  '';

  runScript = "${dist}/expresslrs-configurator";
}
