{
  alsa-lib,
  autoPatchelfHook,
  copyDesktopItems,
  fetchurl,
  fontconfig,
  gcc,
  icu,
  lib,
  libice,
  libsm,
  libusb1,
  libx11,
  makeDesktopItem,
  stdenv,
  util-linux
}:

let

  hash = "d34bf923c";

  platforms = {
    aarch64-linux = {
      arch = "arm64";
      sha256 = "13a8j917yxa4ly5m17lqmj0yz96jlbak0j887kq6f8igvidk9v41";
    };

    x86_64-linux = {
      arch = "x64";
      sha256 = "1cz18y7r0s5dmdiv1vx28zsbvqp7ym0kqdkmjkd9r5kn22qgs8qq";
    };
  };

  version = "1.0.9";

  inherit (stdenv.hostPlatform) system;

in

  with platforms.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  stdenv.mkDerivation rec {
    inherit version;
    pname = "sdrconnect";

    src = fetchurl {
      url = "https://www.sdrplay.com/software/sdrconnect_linux-${arch}_${hash}.tar.gz";
      inherit sha256;
    };

    nativeBuildInputs = [ autoPatchelfHook copyDesktopItems ];

    buildInputs = [
      alsa-lib
      fontconfig
      libusb1
      util-linux # for libuuid
      gcc.cc.lib # for libstdc++
    ];

    runtimeDependencies = [
      icu
      libice
      libsm
      libx11
    ];

    appendRunpaths = [ "${placeholder "out"}/lib" ];

    unpackPhase = ''
      tar xaf $src
    '';

    postInstall = ''
      mkdir -p $out/bin $out/lib $out/share/icons/hicolor/64x64/apps
      cp SDRconnect $out/bin
      cp *.so $out/lib
      cp icons/64x64/sdrconnect.png $out/share/icons/hicolor/64x64/apps
    '';

    desktopItems = with meta; [
      (makeDesktopItem {
        name = pname;
        icon = pname;
        exec = mainProgram;
        comment = description;
        desktopName = "SDRconnect";
        genericName = "SDRplay Client";
        categories = [ "AudioVideo" "HamRadio" ];
        keywords = [ "Ham" "Radio" "SDR" ];
      })
    ];

    meta = with lib; {
      description = "Cross platform GUI client for SDRplay";
      homepage = "https://www.sdrplay.com/sdrconnect/";
      sourceProvenance = with sourceTypes; [ binaryNativeCode ];
      license = licenses.unfree;
      platforms = attrNames platforms;
      mainProgram = "SDRconnect";
    };
  }
