How to run Qt apps on a build-time? (trying to pack TrenchBroom)

Hi. I’m trying to create a package for the awesome TrenchBroom map editor. Actually, somebody has done that before, but that was prior to conversion to the Qt framework (it was on wxWidgets earlier, and the author had even asked for help on the subreddit).

So, here we are. I’ve already done the dirty part to make it start building properly (as the dev prescribed). Here we have release.nix and default.nix. It goes on building both with ninja and with plain CMake. I’m now trying to build it without manual (and thus without pandoc), but stuck on the problem when builder tries running some headless (I’ve checked that!) Qt app to generate shortcuts for (sic) a manual.

[136/150] cd /build/TrenchBroom/app && /nix/store/425drya86sagb5djr8gy625h3mixfnps-cmake-3.13.4/bin/cmake -E make_directory /build/TrenchBroom/app/gen-manual
[137/150] cd /build/TrenchBroom/app && /nix/store/425drya86sagb5djr8gy625h3mixfnps-cmake-3.13.4/bin/cmake -E make_directory /build/TrenchBroom/app/gen-manual/images
...
[141/150] cd /build/TrenchBroom/app && /build/TrenchBroom/dump-shortcuts/dump-shortcuts /build/TrenchBroom/app/gen-manual/shortcuts.js
FAILED: app/gen-manual/shortcuts.js
cd /build/TrenchBroom/app && /build/TrenchBroom/dump-shortcuts/dump-shortcuts /build/TrenchBroom/app/gen-manual/shortcuts.js
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

ninja: build stopped: subcommand failed.
builder for '/nix/store/3i72d9avan9bs6az1jh95qvbp5sxf7r0-TrenchBroom-2020.1u.drv' failed with exit code 1
error: build of '/nix/store/3i72d9avan9bs6az1jh95qvbp5sxf7r0-TrenchBroom-2020.1u.drv' failed

So, how would we let Nix run Qt apps inside the builder? I guess it’s something about wrapping builder with Qt env-vars, but I have no clue how to perform it.

Once again, a bigger link with all the files about the case:

And some meta, just in case:

  • system: "x86_64-linux"
  • host os: Linux 5.4.42, NixOS, 20.09pre226586.571212eb839 (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.4
  • channels(root): "nixos-19.03.173691.34c7eb7545d, nixpkgs-20.09pre226586.571212eb839"
  • channels(user): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
1 Like