Installing MPLAB X IDE requiring FHS

I need to install MPLAB X IDE, which isn’t packaged in nixpkgs, and distributed in .tar archive containing a single installation .sh script.

To do this I created a shell.nix program containing:

{pkgs ? import <nixpkgs> {}}:
(pkgs.buildFHSEnv {
  name = "mplab-env";
  targetPkgs = pkgs:
    with pkgs; [
      jdk17
      libusb1
      libx11
      libxext
      libxi
      libxrender
      libxtst
      libxt
      libxcursor
      libxrandr
      libxfixes
      libxscrnsaver
      fontconfig
      freetype
      glib
      libpng
      coreutils
      gnugrep
      gnused
      psmisc
      util-linux
      stdenv.cc.cc.lib
      zlib
    ];
  multiPkgs = pkgs: with pkgs; [];
  profile = ''
    export MPLAB_HOME=/home/tymur/University/c5s2/decs/mplabx_v6.30
    export PATH=$MPLAB_HOME/mplab_platform/bin:$PATH
  '';
}).env

I had problems with running the installer, as it requires su privileges and nix-shell for some reason disallows using sudo, but I’ve succeeded running sudo nix-shell first, and then running the script.

I’ve chosen the installation directory visible in shell.nix, specifically path MPLAB_HOME.

When installing, I’ve had a few warnings about failing to create “/usr/share/applications” and “…/icons” directories, and writing to them, but those were trying to create .desktop files, which I don’t really need, but tried assisting the script by creating directories myself, failed and so ignored those.

Installation finished seemingly successful, but when trying to run the program, I get:

[tymur@tymurPC:~/University/c5s2/decs]$ mplab_ide 
/home/tymur/University/c5s2/decs/mplabx_v6.30/mplab_platform/bin/mplab_ide: line 91: /etc/.mplab_ide/mchpsegusbmonitor: No such file or directory
Unrecognized VM option 'UseConcMarkSweepGC'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

During installation process I haven’t seen any occurrences of this file, so I don’t really understand why it appears. Can’t provide any useful point here, really.

The installation script contains bash text at the beginning and then the compressed binary. I don’t know how to properly handle such situations; was it a simple binary then buildFHSEnv would do its thing I assume.

Any advice on how to do this? Thank you in advance!

Maybe a more general question would help:

How to create mutable FHS environments, possibly isolated from real “/” subdirectories, so directories like “/usr/” can be safely modified, and not just standalone binaries can work?