Running qt applications with xvfb-run


I’m trying to make the Tiled map editor export a map file in a nix script. I get a segmentation fault when trying in a script, while in my shell this works flawlessly. Here’s a minimal example:

with import <nixpkgs> {};

stdenv.mkDerivation rec {
  name = "test";
  buildInputs = with pkgs; [ tiled xvfb_run ];
  src = ./.;
  QT_PLUGIN_PATH = pkgs.qt5.qtbase.bin + "/" + pkgs.qt5.qtbase.qtPluginPrefix;
  buildPhase = ''
    xvfb-run tiled --export-map $src/map.tmx map.lua

I’m using some QT_PLUGIN_PATH magic because otherwise xcb is not found. Running that example produces /nix/store/qcm3sk20a0wnnf0y1vnz1c4rsj40wb7r-xvfb-run/bin/.xvfb-run-wrapped: line 170: 552 Segmentation fault DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1. I’m not sure if this is a bug in xvfb, tiled, or my own configuration.


Okay, by digging around very unrelated websites, I discovered that by changing the xvfb-run line to

xvfb-run --server-args="-screen 0, 1280x1024x24" tiled --export-map $src/map.tmx map.lua

i was able to run this without segfaults. Don’t really know why this works but seems to be a color depth issue since the defaults are 1280x1024x8 and otherwise the same.

1 Like