{
  alsa-lib,
  cmake,
  fetchFromGitHub,
  fontconfig,
  freetype,
  lib,
  libjack2,
  libX11,
  libXcursor,
  libXext,
  libXinerama,
  libXrandr,
  lv2,
  pkg-config,
  stdenv
}:

stdenv.mkDerivation rec {
  pname = "gearmulator";
  version = "1.4.1";

  src = fetchFromGitHub {
    owner = "dsp56300";
    repo = pname;
    tag = version;
    hash = "sha256-JnXTTtxF5jHPaU+d558JwlGo/QjKHtVuCqel5iaBBCk=";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [
    cmake
    pkg-config
  ];

  buildInputs = [
    alsa-lib
    fontconfig
    freetype
    libjack2
    libX11
    libXcursor
    libXext
    libXinerama
    libXrandr
    lv2
  ];

  env.NIX_LDFLAGS = toString [
    "-ljack"
    "-lX11"
    "-lXcursor"
    "-lXext"
    "-lXinerama"
    "-lXrandr"
  ];

  cmakeFlags = [
    "-Dgearmulator_BUILD_FX_PLUGIN=OFF"
    "-Dgearmulator_BUILD_JUCEPLUGIN=ON"
    "-Dgearmulator_BUILD_JUCEPLUGIN_CLAP=OFF"
    "-Dgearmulator_BUILD_JUCEPLUGIN_LV2=OFF"
    "-Dgearmulator_SYNTH_NODALRED2X=OFF"
    "-Dgearmulator_SYNTH_OSIRUS=OFF"
    "-Dgearmulator_SYNTH_OSTIRUS=ON"
    "-Dgearmulator_SYNTH_VAVRA=OFF"
    "-Dgearmulator_SYNTH_XENIA=OFF"
  ];

  postInstall = ''
    rm $out/{dsp56300EmuServer,start_Impact__MS.sh,start_IndiArp_BC.sh,virusTestConsole}
    rm -r $out/plugins
  '';

  meta = {
    description = "Emulation of Motorola 56300 family DSP synths";
    homepage = "https://github.com/dsp56300/gearmulator";
    license = lib.licenses.gpl3;
    platforms = [ "x86_64-linux" ];
  };
}
