Packaging a Install4J application

Hello! I’m trying to install a Install4J packaged installer on NixOS stable 24.11. The program I am trying to run is an Java Swing application that is built by my employer and needed to set up our dev environment. I have access to the source code but it is also important that I can run the installer.

The Linux packaged installer is a .sh file that should package everything that is needed to run it. It has a 120MB binary chunk appended to it. Running the installer gives the expected error message:

Could not start dynamically linked executable: /home/plip/Downloads/my-program_9.2.0.sh.64923.dir/jre/bin/java
NixOS cannot run dynamically linked executables intended for generic linux environments out of the box. For more information, see: Frequently Asked Questions — nix.dev documentation

Following the link and looking at some other examples I created the following files to make a nix-build

#my-application.nix
{
  stdenv,
  fetchurl,
}:

stdenv.mkDerivation rec {
  pname = "my-application";
  version = "9.2.0";

  src = fetchurl {
    url = "https://.../installer/file/my-application_9.2.0.sh";
    sha256 = "...";
  };

  dontUnpack = true;

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp $src $out/bin/my-application_9.2.0.sh
    chmod +x $out/bin/my-application_9.2.0.sh
    
    echo Starting installer!
    $out/bin/my-application_9.2.0.sh -q
    echo Installed successfully

    runHook postInstall
  '';
}
#default.nix
let
  nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.11";
  pkgs = import nixpkgs { config = {}; overlays = []; };
in
{
  my-application = pkgs.callPackage ./my-applicationq.nix { };
}

With this setup i run nix-build -A my-application and get this error:

error: builder for ‘/nix/store/058kpwzzbj8z627wmi34lxf5fqrpjxil-my-application-9.2.0.drv’ failed with exit code 127;
last 11 log lines:
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
no Makefile or custom buildPhase, doing nothing
Running phase: installPhase
Starting installer!
Unpacking JRE …
Starting Installer …
/nix/store/1a84mad5vw9l9cx7d9ckbbk2dnar8y0m-my-application-9.2.0/bin/my-application_9.2.0.sh: line 628: /nix/store/1a84mad5vw9l9cx7d9ckbbk2dnar8y0m-my-application-9.2.0/bin/my-application_9.2.0.sh.34.dir/jre/bin/java: not found

I have tried adding jdk11 as a buildInput and creating a link to it were the installer is looking for the jre, but with no luck.
The installer bundles an jre that it unpacks at a location and tries to run it but fails. The install scrip is generated by Install4J so I have little control of how it works.

I found this thread that described the same issue Install moneydance
But I did not manage to extract anything useful from it. I did not try to use nix-shell and buildFHSEnv since that did not seem to be the recommended way forward.

So to my question: Is it possible to run this install scrip as a nix package? Or do I need to make my own installer i a package? In that case, how would I go on about doing that?
Could steam-run be a viable option?

I tried to install the steam-run package and ran the installer. It just magically worked out of the box - no issues faced! After running the gui installer the program installed itself under ~/my-application which might not be the most Nix-way to solve things, but it is good enough for me at the moment.

I’ve only been using Nix for about 2 months. I’ll revisit this once I learn of a better solution.