Skip to content

Instantly share code, notes, and snippets.

@samueldr
Created July 30, 2018 01:27
Show Gist options
  • Save samueldr/76942d829b1ecd838520bcadf560691f to your computer and use it in GitHub Desktop.
Save samueldr/76942d829b1ecd838520bcadf560691f to your computer and use it in GitHub Desktop.
TEMPORARY and gross (yuck) workaround for qt not finding platform plugins.

This will only work (as-is) at the root of the same nixpkgs checkout from which you're trying to run a Qt app.

 $ pwd
/my/checkout/nixpkgs
 $ qt-run result/bin/that-qt-software
#!/usr/bin/env bash
# THIS ONLY WORKS WHEN USED AT THE ROOT OF A NIXPKGS CHECKOUT
# OR IF YOU MANIPULATE YOUR NIX PATH.
set -e
set -u
_nb() {
nix-build --no-out-link -A "$@"
}
_qtlibs=(
qt5.qtbase.bin
qt5.qtdeclarative.bin
qt5.qtimageformats.out
qt5.qtlocation.bin
qt5.qtmultimedia.bin
qt5.qtsensors.bin
qt5.qtsvg.bin
)
for attrpath in "${_qtlibs[@]}"; do
_p=$(_nb $attrpath)/bin
PATH="$_p:$PATH"
unset _p
done
exec "$@"
@samueldr
Copy link
Author

This (ab)uses the added behaviour from nixpkgs to Qt that uses PATH components to pre-seed the Qt plugin path. Using QT_PLUGIN_PATH would work as well. I, though, preferred using PATH as they are earlier in the selection.

As for which libs, I used this:

nix-locate -1r qt-5.*plugins/.*so | grep -v '^(' | sort -u

And selected those under qt5.*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment