4kvideodownloaderpilus FHS wrapper fails

4kvideodownloaderplus is a Qt6 application that downloads, unpacks, and executes normally on tested FHS filesystem compliant linux distribtions.

However, numerous attempts to configure a FHS wrapper for proper execution from Mate desktop shortcut with target binary located on a separate shared exFAT partition have failed with program failing to find “xcb” resources, or alternatively, when Nix Qt resources are accessed, a Qt version mismatch occurs.

Since the 4kvideodownloader program is touted as “portable” it would make sense to configure a wrapper environment to require the downloader to utilize its own files within its file tree, before requiring any runtime assets that Nix would need to supply.

A comprehensive FHS wrapper that handles all program requirements, and particularly the “xcb” requirements appears to be necessary and assistance is solicited.

Here is an example of related configuration.nix entries (also includes provisions for Appimages and fuse):

  # -------------------------------------
  # Environment packages
  # -------------------------------------
  environment.systemPackages = with pkgs; [
  gvfs
  udisks2
  appimage-run
  nss
  file
  nftables
  nix-ld
  tree

  # -------------------------------------
  # 4K Video Downloader Plus FHS wrapper
  # -------------------------------------
  (buildFHSEnv {
    name = "4kvideodownloaderplus-fhs";

    targetPkgs = pkgs: with pkgs; [
      stdenv.cc.cc
      stdenv.cc.cc.lib
      zlib
      openssl
      expat
      libGL
      libGLU
      libglvnd
      mesa
      libdrm
      vulkan-loader

      # X11 core
      xorg.libX11
      xorg.libXext
      xorg.libXcursor
      xorg.libXrandr
      xorg.libXrender
      xorg.libXfixes
      xorg.libXi
      xorg.libXcomposite
      xorg.libXdamage
      xorg.libXScrnSaver
      xorg.libXau
      xorg.libXdmcp
      xorg.libXtst
      xorg.libxcb

      # Keyboard support (Qt XCB needs this)
      libxkbcommon      
      libxkbfile

      # XCB utilities
      xorg.xcbutil
      xorg.xcbutilwm
      xorg.xcbutilkeysyms
      xorg.xcbutilimage
      xorg.xcbutilrenderutil
      xorg.xcbutilcursor
      libxcb-cursor
      libxcb-render-util
      libxcb-image
      libxcb-util
      libxcb-errors

      # Fonts / graphics
      fontconfig
      freetype
      cairo
      pango
      harfbuzz
      libpng

      # Audio
      alsa-lib
      libpulseaudio
      pipewire

      # System helpers
      dbus
      glib
      at-spi2-atk
      at-spi2-core
      udev
      nss
      nspr
      cups
    ];

    runScript = "/media/Data/esr/4kvideodownloaderplus/4kvideodownloaderplus.sh";

    profile = ''
      # Ensure the app’s own Qt libs are loaded first
      export LD_LIBRARY_PATH="/media/Data/esr/4kvideodownloaderplus/lib:/media/Data/esr/4kvideodownloaderplus:$LD_LIBRARY_PATH"

      # Then add system libs
      export LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/current-system/sw/lib:$LD_LIBRARY_PATH"

      # Point to shipped Qt platform plugins
      export QT_QPA_PLATFORM_PLUGIN_PATH="/media/Data/esr/4kvideodownloaderplus/platforms"
      export QT_XCB_GL_INTEGRATION="/media/Data/esr/4kvideodownloaderplus/xcbglintegrations"
      export QT_QPA_PLATFORM=xcb
      export QT_QPA_GENERIC_PLUGINS="iconengines,platformthemes"

      # Add binary dir
      export PATH="/media/Data/esr/4kvideodownloaderplus:$PATH"

      export LANG=C.UTF-8
      export LC_ALL=C.UTF-8
    '';
  })
];

# ─────────────────────────────────────────────────────────────
# Dynamic binary / AppImage compatibility layer (complete)
# ─────────────────────────────────────────────────────────────
programs.nix-ld = {
  enable = true;
  package = pkgs.nix-ld;

  libraries = with pkgs; [

    # -------------------------
    # Core runtime
    # -------------------------
    stdenv.cc.cc
    stdenv.cc.cc.lib
    zlib
    zstd
    openssl
    curl
    xz
    bzip2
    expat
    libuuid

    # -------------------------
    # OpenGL / Graphics
    # -------------------------
    libGL
    libglvnd
    mesa
    vulkan-loader
    libdrm

    # -------------------------
    # X11 Core & Extensions
    # -------------------------
    xorg.libX11
    xorg.libXext
    xorg.libXcursor
    xorg.libXtst
    xorg.libXrandr
    xorg.libXi
    xorg.libXrender
    xorg.libXcomposite
    xorg.libXdamage
    xorg.libXfixes
    xorg.libXScrnSaver
    xorg.libXau
    xorg.libXdmcp
    xorg.libxcb
    xorg.libxshmfence
    xorg.libxkbfile

    # xcb-util family
    xorg.xcbutil
    xorg.xcbutilwm
    xorg.xcbutilimage
    xorg.xcbutilkeysyms
    xorg.xcbutilrenderutil
    xorg.xcbutilcursor
    libxcb-cursor       # <--- essential for Qt 6.5+

    # -------------------------
    # Input / Keyboard
    # -------------------------
    libxkbcommon

    # -------------------------
    # Fonts
    # -------------------------
    fontconfig
    freetype
    libpng

    # -------------------------
    # Audio
    # -------------------------
    alsa-lib
    libpulseaudio

    # -------------------------
    # Network / NSS / IPC
    # -------------------------
    nspr
    nss
    dbus
    glib
    udev
  ];
};

programs.fuse.enable = true;

programs.appimage = {
  enable = true;
  binfmt = true;
};

# ─────────────────────────────────────────────────────────────
# Systemd tmpfiles rules to provide FHS-compatible loader & mount points
# ─────────────────────────────────────────────────────────────
systemd.tmpfiles.rules = lib.mkAfter [
  # Ensure /lib64 exists
  "d /lib64 0755 root root -"

  # Symlink nix-ld dynamic loader to expected FHS path
  "L+ /lib64/ld-linux-x86-64.so.2 - - - - /run/current-system/sw/share/nix-ld/lib/ld.so"

  # Loop mount directories
  "d /media/loop4 0755 root root - -"
  "d /media/loop5 0755 root root - -"
  "d /media/loop6 0755 root root - -"
  "d /media/loop7 0755 root root - -"
  "d /media/loop8 0755 root root - -"
  "d /media/loop9 0755 root root - -"
  "d /media/loop10 0755 root root - -"
];

program failure to execute:

4kvideodownloaderplus-fhs
QEventLoop: Cannot be used without QApplication
[2026-02-25 17:38:24.868363] [0x00007f46acff9680] [info]    started
[2026-02-25 17:38:24.868458] [0x00007f46ac7f8680] [info]    started
[2026-02-25 17:38:24.868485] [0x00007f46ab7f6680] [info]    started
[2026-02-25 17:38:24.868503] [0x00007f46abff7680] [info]    started
[2026-02-25 17:38:24.868566] [0x00007f46aaff5680] [info]    started
[2026-02-25 17:38:24.868671] [0x00007f46aa7f4680] [info]    started
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/media/Data/esr/4kvideodownloaderplus/platforms" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

/media/Data/esr/4kvideodownloaderplus/4kvideodownloaderplus.sh: line 9: 76259 Aborted                    (core dumped) "$SCRIPT_DIR"/4kvideodownloaderplus-bin $*

find /nix/store -name 'libxcb-cursor*'
/nix/store/7ml5x6rs5mvrksh1rajyzq3kgbpysp2v-ld-library-path/share/nix-ld/lib/libxcb-cursor.so
/nix/store/7ml5x6rs5mvrksh1rajyzq3kgbpysp2v-ld-library-path/share/nix-ld/lib/libxcb-cursor.so.0.0.0
/nix/store/7ml5x6rs5mvrksh1rajyzq3kgbpysp2v-ld-library-path/share/nix-ld/lib/libxcb-cursor.la
/nix/store/7ml5x6rs5mvrksh1rajyzq3kgbpysp2v-ld-library-path/share/nix-ld/lib/libxcb-cursor.so.0
/nix/store/cyhkpcc06gv501j5780x3spgwk5d8blw-nixos-25.11/nixos/pkgs/by-name/li/libxcb-cursor
f/nix/store/pm8lvpg5vxbms4ydgsascg9309g1czr5-libxcb-cursor-0.1.6/lib/libxcb-cursor.so
/nix/store/pm8lvpg5vxbms4ydgsascg9309g1czr5-libxcb-cursor-0.1.6/lib/libxcb-cursor.so.0.0.0
/nix/store/pm8lvpg5vxbms4ydgsascg9309g1czr5-libxcb-cursor-0.1.6/lib/libxcb-cursor.la
/nix/store/pm8lvpg5vxbms4ydgsascg9309g1czr5-libxcb-cursor-0.1.6/lib/libxcb-cursor.so.0
/nix/store/gg8ycf2s5a5h1vyjvb7xc7xrq6wnijlg-ld-library-path/share/nix-ld/lib/libxcb-cursor.so
/nix/store/gg8ycf2s5a5h1vyjvb7xc7xrq6wnijlg-ld-library-path/share/nix-ld/lib/libxcb-cursor.so.0.0.0
/nix/store/gg8ycf2s5a5h1vyjvb7xc7xrq6wnijlg-ld-library-path/share/nix-ld/lib/libxcb-cursor.la
/nix/store/gg8ycf2s5a5h1vyjvb7xc7xrq6wnijlg-ld-library-path/share/nix-ld/lib/libxcb-cursor.so.0
/nix/store/qnlc6pcxjnk0c56fxk4zpix7fp7y1ys0-system-path/lib/libxcb-cursor.so
/nix/store/qnlc6pcxjnk0c56fxk4zpix7fp7y1ys0-system-path/lib/libxcb-cursor.so.0.0.0
/nix/store/qnlc6pcxjnk0c56fxk4zpix7fp7y1ys0-system-path/lib/libxcb-cursor.la
/nix/store/qnlc6pcxjnk0c56fxk4zpix7fp7y1ys0-system-path/lib/libxcb-cursor.so.0
/nix/store/kms1ymkz63ijkfjnl6803dx2mynmdwji-nixos-25.11/nixos/pkgs/by-name/li/libxcb-cursor
/nix/store/rwvyq4r7aq5fchdm2mvyay2h8fvsm3jf-nixos-25.11/nixos/pkgs/by-name/li/libxcb-cursor

ls '/media/Data/esr/4kvideodownloaderplus' 
4kvideodownloaderplus-bin                 libQt6QuickLayouts.so.6
4kvideodownloaderplus.sh                  libQt6QuickShapes.so.6
audio                                     libQt6Quick.so.6
doc                                       libQt6QuickTemplates2.so.6
icudtl.dat                                libQt6QuickWidgets.so.6
imageformats                              libQt6ShaderTools.so.6
libavcodec.so.58                          libQt6Svg.so.6
libavformat.so.58                         libQt6WebChannelQuick.so.6
libavutil.so.56                           libQt6WebChannel.so.6
libcrypto.so.1.1                          libQt6WebEngineCore.so.6
liblalalai_proc.so                        libQt6WebEngineQuick.so.6
libonnxruntime_providers_cuda.so          libQt6WebEngineWidgets.so.6
libonnxruntime_providers_shared.so        libQt6WebView.so.6
libonnxruntime_providers_tensorrt.so      libQt6Widgets.so.6
libonnxruntime.so.1                       libQt6XcbQpa.so.6
libportaudio.so                           libQt6Xml.so.6
libpostproc.so.55                         libssl.so.1.1
libQt6Concurrent.so.6                     libswresample.so.3
libQt6Core5Compat.so.6                    libswscale.so.5
libQt6Core.so.6                           locales
libQt6Gui.so.6                            networkinformation
libQt6LabsPlatform.so.6                   platforminputcontexts
libQt6LabsQmlModels.so.6                  platforms
libQt6Location.so.6                       platformthemes
libQt6Network.so.6                        position
libQt6OpenGL.so.6                         Qt
libQt6PositioningQuick.so.6               Qt5Compat
libQt6Positioning.so.6                    QtNetwork
libQt6PrintSupport.so.6                   QtQml
libQt6QmlMeta.so.6                        QtQuick
libQt6QmlModels.so.6                      QtWebEngine
libQt6Qml.so.6                            qtwebengine_devtools_resources.pak
libQt6QmlWorkerScript.so.6                QtWebEngineProcess
libQt6QuickControls2Basic.so.6            qtwebengine_resources_100p.pak
libQt6QuickControls2BasicStyleImpl.so.6   qtwebengine_resources_200p.pak
libQt6QuickControls2Fusion.so.6           qtwebengine_resources.pak
libQt6QuickControls2FusionStyleImpl.so.6  tls
libQt6QuickControls2Impl.so.6             v8_context_snapshot.bin
libQt6QuickControls2.so.6                 webview
libQt6QuickEffects.so.6                   xcbglintegrations

#####-end of data-#####