Help with packaging gearmulator plugins

I’ve been trying to locally package and hopefully eventually submit a build recipe for the fantastic gearmulator set of plugins. Here’s a link to my current version of things.

The problem is, as soon as the UI attempts to load, the plugin crashes and crashes Reaper also. If I select the option in Reaper to “Default VST to generic UI”, it loads fine and plays sound. Without that option or clicking on the UI button inside the generic interface, it crashes everything.

The really aggravating part, is that I actually had a working UI for all of the plugins when I first started messing with this to try to build the initial recipe, but I had been doing that without checking everything in and was using nix build path://${PWD}#gearmulator to test things initially. At that point, I wasn’t even attempting to use NIX_LDFLAGS in the recipe, but ended up including that later as a lot of the other JUCE based plugins already packaged for Nix seem to do that (adlplug, chow-tape-model, dexed, odin2, show-midi, surge-XT all do this). I’ve tried it with and without the env prefix to no avail. I think when I had it working initially, I wasn’t specifying any of this.

But at this point, the best I can achieve for whatever reason is if I set gearmulator_SYNTH_NODALRED2X=ON to include that plugin, it will actually draw the plugin UI and immediately hang and crash. I’ve been testing with the OsTIrus plugin otherwise simply to reduce the rebuild times as I’ve been trying a lot of different variations and that never even paints the UI, it just crashes upon attempting to enable the UI.

I also tried Carla as another plugin host and it crashes every time no matter what. But it doesn’t have an option that I see to enable only the generic UI like Reaper, so I’m assuming it’s trying to paint the UI every time upon loading and therefore crashes.

I’m hoping someone here can see the obvious thing I’m doing wrong.

I’ll just throw the recipe I’m working on here directly for now so when I inevitably end up trying to tackle this again, it will at least be in the current, somewhat broken state for people to be able to reference:

{
  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" ];
  };
}