Need help with getting the libraries for BIOVIA Discovery Studio Visualizer

I want to run BIOVIA Discovery Studio Visualizer 2025 on NixOS 25.05. It’s installed via a .bin file. I’ve run the installer, but to run the app it seems I’ll need to set up nix-ld with these libraries:

alsa-lib
audit-libs
bc
bzip2-libs
cairo
compat-libstdc++-33
compat-libtiff3
e2fsprogs-libs
expat
fontconfig
freetype
gd
glib2
glibc
keyutils-libs
krb5-libs
libdrm
libgcc
libICE
libjpeg-turbo
libnsl
libpcap
libpng15
libselinux
libsepol
libSM
libstdc++
libX11
libXau
libXdamage
libXdmcp
llibXext
libXfixes
libXi
libXinerama
libXmu
libXpm
libXrender
libXt
libXtst
libXxf86vm
pam
tcsh
zlib

Many of these I’ve found in NixOS’ repos. I’ve added these libraries to nix-ld:

alsa-lib
        audit
        cairo
        libtiff
        e2fsprogs
        expat
        fontconfig
        freetype
        gd
        glib
        glibc
        keyutils
        krb5
        libdrm
        libgcc
        #libstdcxx
        bc
        bzip2
        xorg.libICE
        #libice
        libjpeg_turbo
        libnsl
        libpcap
        libpng
        libselinux
        libsepol
        xorg.libSM
        #libsm
        #libx11
        xorg.libX11
        #libxau
        xorg.libXau
        #libxdamage
        xorg.libXdamage
        zlib
        tcsh
        pam_krb5
        pam_p11
        #libxxf86vm
        xorg.libXxf86vm
        #libxtst
        xorg.libXtst
        #libxt
        xorg.libXt
        #libxrender
        xorg.libXrender
        #libxpm
        xorg.libXpm
        #libxmu
        xorg.libXmu
        #libxinerama
        xorg.libXinerama
        #libxi
        xorg.libXi
        #libxfixes
        xorg.libXfixes
        #libxext
        xorg.libXext
        #libxdmcp
        xorg.libXdmcp

Now BIOVIA Discovery Studio Visualizer complains libpcre2-16.so is missing when I try to launch it. I tried adding tests.pkg-config.defaultPkgConfigPackages.libpcre2-16 to nix-ld, but this lead to the rebuild error:

these 12 derivations will be built:
  /nix/store/q4ppbkf319f7gi4x848kqjgnnyj7hwl0-ld-library-path.drv
  /nix/store/ggqs6phmysffnw2ziv680w4b3mig6xbg-system-path.drv
  /nix/store/wrvfm7l1i7lvq94qpipkz51fbvmzgvak-X-Restart-Triggers-polkit.drv
  /nix/store/bnl9q1d6l167fm523z94k6qws9cyhpcc-unit-polkit.service.drv
  /nix/store/kyr5l7j37g07d6r7aa75wm4wr0a3mhs3-dbus-1.drv
  /nix/store/jb65d7vxnwcvf9bwigdv7a061fa7s9ka-X-Restart-Triggers-dbus.drv
  /nix/store/lqxx4rivgvm7l567hna1d148wadmwcw2-unit-dbus.service.drv
  /nix/store/985ai7a9pq3hpipf6s091psr7qiqkj05-system-units.drv
  /nix/store/pgxpffrviy22wp4y4xi0qrxkwgf75v6k-unit-dbus.service.drv
  /nix/store/srbvchfnxhiiji96vivq2qjgm453sd9k-user-units.drv
  /nix/store/sv9f21ynk5li3brh5zgzvg36m2i17rps-etc.drv
  /nix/store/8nmr2w27csk64zadm48s0217ab3padfd-nixos-system-nixos-25.05.812242.3de8f8d73e35.drv
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/c77lrxzaqfm9d17iqapwi94rbs2gzmax-check-pkg-config-pcre2
copying path '/nix/store/c77lrxzaqfm9d17iqapwi94rbs2gzmax-check-pkg-config-pcre2' from 'https://cache.nixos.org'...
building '/nix/store/q4ppbkf319f7gi4x848kqjgnnyj7hwl0-ld-library-path.drv'...
warning: collision between `/nix/store/5cdzaagddbzip0rd0f9bfkfnq143bxd8-krb5-1.21.3-lib/lib/libcom_err.so' and `/nix/store/ldlkl531yapf8xwla348lx4xqik5a69v-e2fsprogs-1.47.2/lib/libcom_err.so'
error: The store path /nix/store/c77lrxzaqfm9d17iqapwi94rbs2gzmax-check-pkg-config-pcre2 is a file and can't be merged into an environment using pkgs.buildEnv! at /nix/store/2awfh7sr3vf9d0ir666fi5qm03ng35sp-builder.pl line 115.
error: builder for '/nix/store/q4ppbkf319f7gi4x848kqjgnnyj7hwl0-ld-library-path.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/ggqs6phmysffnw2ziv680w4b3mig6xbg-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/8nmr2w27csk64zadm48s0217ab3padfd-nixos-system-nixos-25.05.812242.3de8f8d73e35.drv' failed to build

After weeks of trying, I finally have a solution! And it is thanks to Antigravity and its AI assistants, and partly thanks to my own mind.

Namely, after hours of debugging issues and my suggesting strace/GDB to help debug the issues, we finally arrived at this commit. It seems I needed this line in configuration.nix:

(import ./ds-fhs-env.nix { inherit pkgs; })

under the systemPackages array, with this ds-fhs-env.nix:

{ pkgs ? import <nixpkgs> { } }:

pkgs.buildFHSEnv {
  name = "ds-fhs-env";

  # -----------------------------------------------------------------
  # Packages that will be present inside the sandbox
  # -----------------------------------------------------------------
  targetPkgs = pkgs:
    with pkgs; [
      # Core utilities
      glibc
      # Core utilities and libraries
      coreutils
      gawk
      gnugrep
      gnused
      findutils
      which
      file

      # Shell
      bash

      # X11 & graphics libraries
      xorg.libX11
      xorg.libXext
      xorg.libXrender
      xorg.libXtst
      xorg.libXi
      xorg.libXmu
      xorg.libXpm
      xorg.libXau
      xorg.libXdmcp
      xorg.libXfixes
      xorg.libXdamage
      xorg.libXinerama
      xorg.libXxf86vm
      xorg.libSM
      xorg.libICE
      xorg.libXrandr
      xorg.libXcursor
      xorg.libXcomposite
      xorg.libxcb
      xorg.xcbutil
      xorg.xcbutilimage
      xorg.xcbutilkeysyms
      xorg.xcbutilrenderutil
      xorg.xcbutilwm

      # OpenGL and GPU acceleration
      libglvnd
      libGLU
      mesa
      libgbm
      libdrm
      qt5.qtbase # already present, but also add:
      qt5.qtx11extras
      qt5.qtwebengine # Explicitly add WebEngine
      # libglvnd-glx  # removed – not a separate package in nixpkgs
      xorg.libxshmfence
      xorg.libXrandr
      xorg.libXrender
      xorg.libXfixes

      # Basic libraries
      glib
      glibc
      zlib
      fontconfig
      freetype
      cairo
      expat
      dbus
      systemd # Provides libudev.so.0

      # Network libraries
      curl
      openssl

      # Additional libraries from your nix‑ld config
      alsa-lib
      audit
      libtiff
      e2fsprogs
      gd
      keyutils
      krb5
      libdrm
      libgcc
      bzip2
      libjpeg_turbo
      libnsl
      libpcap
      libpng
      libselinux
      libxcrypt-legacy # Added by instruction
      libsepol
      tcsh
      pam_krb5
      pam_p11
      libxcrypt-legacy # Added by instruction

      # **NEW – libxcrypt (provides libcrypt.so.1)**
      libxcrypt

      # Additional runtime dependencies
      stdenv.cc.cc.lib
      libxkbcommon
      nspr
      nss
      cups
      zstd

      # Graphics & Hardware
      numactl
      glxinfo
      vulkan-loader
      libglvnd

      # Additional libraries for Discovery Studio
      gcc-unwrapped.lib # Provides libstdc++.so.6, libgcc_s.so.1, etc.
      boost
      xercesc
      libxslt

      # Additional debugging and support libraries
      libunwind
      libatomic_ops

      # XDG utilities for file associations
      xdg-utils
      shared-mime-info

      # Additional libraries for WebEngine and graphics
      pango
      gdk-pixbuf
    ];

  # -----------------------------------------------------------------
  # Environment that will be sourced when you enter the sandbox
  # -----------------------------------------------------------------
  extraMounts = [{
    source = "/dev/dri";
    target = "/dev/dri";
    isReadOnly = false;
  }];

  profile = ''
    # Prioritize bundled libraries (Qt, etc.) over system ones to avoid ABI conflicts
    export LD_LIBRARY_PATH=$HOME/BIOVIA/DiscoveryStudio2025/lib:$out/lib:$out/lib64:/lib:/lib64:/usr/lib:/usr/lib64:$LD_LIBRARY_PATH

    # Point Qt to the bundled plugins
    export QT_PLUGIN_PATH=$HOME/BIOVIA/DiscoveryStudio2025/lib
    unset QT_QPA_PLATFORM_PLUGIN_PATH

    # Force X11 backend (more stable for proprietary apps)
    export QT_QPA_PLATFORM=xcb
    export XDG_SESSION_TYPE=x11

    # Graphics Configuration
    # Try to use hardware rendering by default
    export LIBGL_ALWAYS_SOFTWARE=0

    # Disable indirect rendering (unless needed for forwarding) to prefer direct hardware access
    export LIBGL_ALWAYS_INDIRECT=0

    # Qt/WebEngine Flags
    export QTWEBENGINE_DISABLE_SANDBOX=1
    # Removed --use-software-gl-implementation to try hardware first
    export QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu-compositing --disable-web-security --disable-extensions --disable-plugins --disable-client-side-phishing-detection"

    export QT_XCB_GL_INTEGRATION=xcb_glx
    export QTWEBENGINE_PROCESS_MODEL=SingleProcess

    # Discovery Studio helpers
    export BIOVIA_HOME=$HOME/BIOVIA/DiscoveryStudio2025
    export BIOVIA_LIC_PACK_DIR=$HOME/BIOVIA/BIOVIA_LicensePack
  '';

  # -----------------------------------------------------------------
  # Create /bin/csh symlink (needed by the license scripts)
  # -----------------------------------------------------------------
  extraInstallCommands = ''
    ln -sf ${pkgs.tcsh}/bin/tcsh $out/bin/csh
  '';
}

I also created this dsv.desktop file for launching it:

[Desktop Entry]
Name=BIOVIA Discovery Studio Visualizer 2025
Icon=DSV
Exec=ds-fhs-env -c '$HOME/BIOVIA/DiscoveryStudio2025/bin/DiscoveryStudio2025'
Type=Application