2

I'm building a QML application on Ubuntu 18.04 and want to setup my development environment using nix (and nixpkgs). However the QML import paths are messed up. If I run the application, I get:

qrc:/main.qml:14 Type ToolButton unavailable

file:///nix/store/013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin/lib/qt-5.12/qml/QtQuick/Controls.2/Material/qmldir:-1 plugin cannot be loaded for module ".nix.store.013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin.lib.qt-5.12.qml.QtQuick.Controls.Material":

Module namespace 'QtQuick.Controls.Material' does not match import URI '.nix.store.013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin.lib.qt-5.12.qml.QtQuick.Controls.Material'

Setting QML2_IMPORT_PATH to /nix/store/013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin/lib/qt-5.12/qml/ solves the problem, thus I reckon that I somehow fail to setup my nix-shell / environment.

Printing the QLibraryInfo::Qml2ImportsPath yields /nix/store/fjxzlpc693gbkgbh1vi199jvzgrkps4j-qtbase-5.12.0/lib/qt-5.12/qml and the import paths of the QML engine are:

  • qrc:/qt-project.org/imports
  • /nix/store/013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin/lib/qt-5.12/qml
  • /nix/store/q02n0gycm1m2sqwzf4ccfysk8bh21jjq-user-environment/lib/qt-5.12/qml
  • /nix/store/pf1ybjg0lh5y1rvalkdfw0axgd1dabpd-qtdeclarative-5.12.0-bin/lib/qt-5.12/qml

My shell.nix looks like this:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  # this will make all the build inputs from hello and gnutar
  # available to the shell environment
  inputsFrom = with pkgs; [ ];
  buildInputs = with pkgs; [ range-v3 boost fmt gbenchmark cmake ninja valgrind gcc gtest graphviz qt5.qtbase qt5.qtdeclarative ];
}

And I've tried it with nix-shell shell.nix and with nix-shell --show-trace -E 'with import <nixpkgs> {}; libsForQt5.callPackage ./shell.nix { }'.

How do I correctly setup the environment / nix-shell without setting QML2_IMPORT_PATH?

Community
  • 1
  • 1
Panke
  • 144
  • 7

0 Answers0