Options for packaging a complex (py)QT application: ChimeraX

Dear community,

I am struggling a bit on getting a software package run on

First of all: My primary goal is to get it to run, no matter in which way. Therefore, I was going for the pre-built package provided on the ChimeraX website (Download UCSF ChimeraX) trying to get it to run via buildFHSUserEnv:

# my fhsenv.nix
let
  pkgs = import <nixpkgs> {};
in pkgs.buildFHSUserEnv {
  name = "fhs";
  targetPkgs = pkgs: [
    pkgs.glib
    pkgs.libGL
    pkgs.libxkbcommon
    pkgs.fontconfig
    pkgs.qt6.qtbase
    # pkgs.haskellPackages.stack
  ];
}

This fails unfortunately for no reason I would be able to comprehend (presumably the xcb plugin delivered with ChimeraX is not compatible with my installed Qt-system?). Of note, using the plugins directory of my system($QT_QPA_PLATFORM_PLUGIN_PATH=/nix/store/pvb668ggghwccpbpzmjqcbm0pans7cnc-qtbase-5.15.3-bin/lib/qt-5.15.3/plugins) also leads to the same error:

(base) fhs-chrootenv:moritz@mopad:~/Downloads/chimerax-1.4$ QT_QPA_PLATFORM_PLUGIN_PATH=./lib/python3.9/site-packages/PyQt6/Qt6/plugins/ ./ChimeraX
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "./lib/python3.9/site-packages/PyQt6/Qt6/plugins/" 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: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-egl, wayland, xcb.

Fatal Python error: Aborted

Current thread 0x00007f22325d4b80 (most recent call first):
  File "/home/moritz/Downloads/chimerax-1.4/lib/python3.9/site-packages/chimerax/ui/gui.py", line 163 in __init__
  File "/home/moritz/Downloads/chimerax-1.4/lib/python3.9/site-packages/ChimeraX_main.py", line 580 in init
  File "/home/moritz/Downloads/chimerax-1.4/lib/python3.9/site-packages/ChimeraX_main.py", line 1021 in <module>
  File "/home/moritz/Downloads/chimerax-1.4/lib/python3.9/runpy.py", line 87 in _run_code
  File "/home/moritz/Downloads/chimerax-1.4/lib/python3.9/runpy.py", line 197 in _run_module_as_main
Aborted (core dumped)

In the ideal scenario, there would be a simple fix for the mentioned error, however if there is none, I would like to ask for advice on which way to take to package this software most efficiently (in terms of effort):

  • There is the prebuilt package I used for my BuildFHSUserEnv-attempts (tar-ball containing lib/, bin/, share/, include/ directories)
  • There are .deb- and .rpm-packages (Download UCSF ChimeraX)
  • The source code is available here: https://github.com/RBVI/ChimeraX/, however I am not sure if I want to comprehend their Makefile-based build system to a degree that allows me to package the software in nix.

I have been using and hacking nixos for a while now, but I am still far from fluent in writing new packages.

Thank you for any advice you might have,

Moritz

Small update:

  • Building from source code is a nightmare and discouraged (authors: “Compiling ChimeraX can be challenging because it depends on more than 50 dependencies. We recommend using a prebuilt ChimeraX”)
  • Likewise the deb-package they provide relies on 50 dependencies. I tried “translating” them to nixos, but already for the 3rd one I tried there is a major version mismatch to nixpkgs
  • The only remaining option seems to be to go with the self-sufficient tarball (which does contain all the required libraries).

Could you please point me towards a direction on how to fix the Qt problem?

Thank you,
Moritz

You might try your luck with steam-run, I’m successfully running relatively complex things like XPlane11 with it on nixos.

I quickly tried with QT_DEBUG_PLUGINS=1 steam-run chimerax-1.4/bin/ChimeraX: there is still a library problem, but maybe that can be solved by just adding generic ones in the program tree, if it’s just a few…

2 Likes

I also started down this path - but in the end I ended up using distrobox + a fedora container and their rpm package to get it running. Works fine and I can’t see the performance impact; but clearly not ideal.

1 Like

This worked, thank you!

QT_DEBUG_PLUGINS=1 (which I didn’t know about before) unveiled a couple of libraries missing (and leading to that “Could not load the Qt platform plugin xcb”-error).

I added theses libraries in a particularly hacky feshion (searched them with ‘locate’ and added the corresponding paths manually via $LD_LIBRARY_PATH)

Great to hear you solved it; I’d very much appreciate a flake / derivation if it can be wrapped up.

1 Like

So would I! I really just used steam-run and manually added libraries that were missing with LD_LIBRARY_PATH. Unfortunately I don’t have the time at the moment to tinker any further with NixOS

@moritzschaefer @TheAncientGoat
come to think of it, maybe the easy (and actually ideomatic) way forward is to “inherit”/instantiate the steam-run env from a new nix-shell definition which also includes the LD_LIBRARY_PATH composed of ${pkg....} references from the buildInputs, where the latter consists of the steam-run list // a user defined list in the mentioned shell.nix. This one could even fetch and unzip the (in this case) chimeraX archive and spawn it with a shell hook, which would lead to a self-contained, automatic solution piggy-backing off of the powerful steam-run.

I’m unfortunately also short on time currently to play with this concept… (And am constinuously struggeling with all kinds of dev-shells and wrongly referenced/prioritised paths and libs)

1 Like