about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/qt-5/5.15/qtdeclarative-qml-paths.patch
blob: e207fa4df3bd4e5675beb9ccda9ad95a6685442c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 289f11d006..9b0a48c6c7 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1897,17 +1897,22 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e)
     addImportPath(installImportsPath);
 
     // env import paths
-    if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QML2_IMPORT_PATH"))) {
-        const QString envImportPath = qEnvironmentVariable("QML2_IMPORT_PATH");
+    auto addEnvImportPath = [this](const char *var) {
 #if defined(Q_OS_WIN)
         QLatin1Char pathSep(';');
 #else
         QLatin1Char pathSep(':');
 #endif
-        QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts);
-        for (int ii = paths.count() - 1; ii >= 0; --ii)
-            addImportPath(paths.at(ii));
-    }
+        if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty(var))) {
+            const QString envImportPath = qEnvironmentVariable(var);
+            QStringList paths = envImportPath.split(pathSep, Qt::SkipEmptyParts);
+            for (int ii = paths.count() - 1; ii >= 0; --ii)
+                addImportPath(paths.at(ii));
+        }
+    };
+
+    addEnvImportPath("QML2_IMPORT_PATH");
+    addEnvImportPath("NIXPKGS_QT5_QML_IMPORT_PATH");
 
     addImportPath(QStringLiteral("qrc:/qt-project.org/imports"));
     addImportPath(QCoreApplication::applicationDirPath());