2

我正在 Ubuntu 18.04 上构建 QML 应用程序,并希望使用 nix(和 nixpkgs)设置我的开发环境。但是 QML 导入路径搞砸了。如果我运行应用程序,我会得到:

qrc:/main.qml:14 类型工具按钮不可用

file:///nix/store/013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin/lib/qt-5.12/qml/QtQuick/Controls.2/Material/qmldir:-1插件无法为模块“.nix.store加载.013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin.lib.qt-5.12.qml.QtQuick.Controls.Material”:

模块命名空间“QtQuick.Controls.Material”与导入 URI“.nix.store.013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin.lib.qt-5.12.qml.QtQuick.Controls.Material”不匹配

设置QML2_IMPORT_PATH/nix/store/013khcq6bcf1ln51wi6b2vk1xq2hx3ys-qtquickcontrols2-5.12.0-bin/lib/qt-5.12/qml/解决问题,因此我认为我无法设置我的 nix-shell / 环境。

打印 QLibraryInfo::Qml2ImportsPath 产量/nix/store/fjxzlpc693gbkgbh1vi199jvzgrkps4j-qtbase-5.12.0/lib/qt-5.12/qml和 QML 引擎的导入路径是:

  • 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

我的 shell.nix 看起来像这样:

{ 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 ];
}

我已经用nix-shell shell.nix和 试过了nix-shell --show-trace -E 'with import <nixpkgs> {}; libsForQt5.callPackage ./shell.nix { }'

如何在不设置 QML2_IMPORT_PATH 的情况下正确设置环境/nix-shell?

4

0 回答 0