qt58: determine plugin and import paths from PATH

Plugin and QML import paths were previously determined by NIX_PROFILES. Using
PATH instead allows Qt applications to work under nix-shell without further
modification.

Changed files
+19 -87
nixos
modules
services
x11
display-managers
pkgs
applications
display-managers
development
+4 -2
nixos/modules/services/x11/display-managers/sddm.nix
···
logsXsession = true;
environment = {
-
# Take themes system environment
-
NIX_PROFILES = "/run/current-system/sw";
+
# Load themes from system environment
+
QT_PLUGIN_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtPluginPrefix;
+
QML2_IMPORT_PATH = "/run/current-system/sw/" + pkgs.qt5.qtbase.qtQmlPrefix;
+
XDG_DATA_DIRS = "/run/current-system/sw/share";
};
-24
pkgs/applications/display-managers/sddm/sddm-nix-profiles.patch
···
-
Index: sddm-0.14.0/src/daemon/Greeter.cpp
-
===================================================================
-
--- sddm-0.14.0.orig/src/daemon/Greeter.cpp
-
+++ sddm-0.14.0/src/daemon/Greeter.cpp
-
@@ -157,18 +157,7 @@ namespace SDDM {
-
<< args;
-
-
// greeter environment
-
- QProcessEnvironment env;
-
- QProcessEnvironment sysenv = QProcessEnvironment::systemEnvironment();
-
-
-
- insertEnvironmentList({QStringLiteral("LANG"), QStringLiteral("LANGUAGE"),
-
- QStringLiteral("LC_CTYPE"), QStringLiteral("LC_NUMERIC"), QStringLiteral("LC_TIME"), QStringLiteral("LC_COLLATE"),
-
- QStringLiteral("LC_MONETARY"), QStringLiteral("LC_MESSAGES"), QStringLiteral("LC_PAPER"), QStringLiteral("LC_NAME"),
-
- QStringLiteral("LC_ADDRESS"), QStringLiteral("LC_TELEPHONE"), QStringLiteral("LC_MEASUREMENT"), QStringLiteral("LC_IDENTIFICATION"),
-
- QStringLiteral("LD_LIBRARY_PATH"),
-
- QStringLiteral("QML2_IMPORT_PATH"),
-
- QStringLiteral("QT_PLUGIN_PATH"),
-
- QStringLiteral("XDG_DATA_DIRS")
-
- }, sysenv, env);
-
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
-
-
env.insert(QStringLiteral("PATH"), mainConfig.Users.DefaultPath.get());
-
env.insert(QStringLiteral("DISPLAY"), m_display->name());
+1 -2
pkgs/applications/display-managers/sddm/series
···
-
sddm-ignore-config-mtime.patch
-
sddm-nix-profiles.patch
+
sddm-ignore-config-mtime.patch
-1
pkgs/development/libraries/qt-5/5.8/qtbase/default.nix
···
-docdir $out/$qtDocPrefix"
NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QT_PLUGIN_PREFIX=\"$qtPluginPrefix\""
-
NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QPA_PLATFORM_PLUGIN_PATH=\"''${!outputLib}/$qtPluginPrefix/platforms\""
'';
+6 -6
pkgs/development/libraries/qt-5/5.8/qtbase/nix-profiles-library-paths.patch pkgs/development/libraries/qt-5/5.8/qtbase/library-paths.patch
···
QStringList *app_libpaths = new QStringList;
coreappdata()->app_libpaths.reset(app_libpaths);
-
+ // Add library paths derived from NIX_PROFILES.
-
+ const QStringList profiles = QFile::decodeName(qgetenv("NIX_PROFILES")).split(' ');
-
+ const QString plugindir = QStringLiteral(NIXPKGS_QT_PLUGIN_PREFIX);
-
+ for (const QString &profile: profiles) {
-
+ if (!profile.isEmpty()) {
-
+ app_libpaths->append(profile + QDir::separator() + plugindir);
+
+ // Add library paths derived from PATH
+
+ const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
+
+ const QString plugindir = QStringLiteral("../" NIXPKGS_QT_PLUGIN_PREFIX);
+
+ for (const QString &path: paths) {
+
+ if (!path.isEmpty()) {
+
+ app_libpaths->append(QDir::cleanPath(path + QDir::separator() + plugindir));
+ }
+ }
+
-43
pkgs/development/libraries/qt-5/5.8/qtbase/qpa-platform-plugin-path.patch
···
-
Index: qtbase-opensource-src-5.8.0/src/gui/kernel/qplatformintegrationfactory.cpp
-
===================================================================
-
--- qtbase-opensource-src-5.8.0.orig/src/gui/kernel/qplatformintegrationfactory.cpp
-
+++ qtbase-opensource-src-5.8.0/src/gui/kernel/qplatformintegrationfactory.cpp
-
@@ -62,9 +62,10 @@ QPlatformIntegration *QPlatformIntegrati
-
// Try loading the plugin from platformPluginPath first:
-
if (!platformPluginPath.isEmpty()) {
-
QCoreApplication::addLibraryPath(platformPluginPath);
-
- if (QPlatformIntegration *ret = qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin>(directLoader(), platform, paramList, argc, argv))
-
- return ret;
-
}
-
+ QCoreApplication::addLibraryPath(QLatin1String(NIXPKGS_QPA_PLATFORM_PLUGIN_PATH));
-
+ if (QPlatformIntegration *ret = qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin>(directLoader(), platform, paramList, argc, argv))
-
+ return ret;
-
#else
-
Q_UNUSED(platformPluginPath);
-
#endif
-
@@ -84,15 +85,16 @@ QStringList QPlatformIntegrationFactory:
-
#ifndef QT_NO_LIBRARY
-
if (!platformPluginPath.isEmpty()) {
-
QCoreApplication::addLibraryPath(platformPluginPath);
-
- list = directLoader()->keyMap().values();
-
- if (!list.isEmpty()) {
-
- const QString postFix = QLatin1String(" (from ")
-
- + QDir::toNativeSeparators(platformPluginPath)
-
- + QLatin1Char(')');
-
- const QStringList::iterator end = list.end();
-
- for (QStringList::iterator it = list.begin(); it != end; ++it)
-
- (*it).append(postFix);
-
- }
-
+ }
-
+ QCoreApplication::addLibraryPath(QLatin1String(NIXPKGS_QPA_PLATFORM_PLUGIN_PATH));
-
+ list = directLoader()->keyMap().values();
-
+ if (!list.isEmpty()) {
-
+ const QString postFix = QLatin1String(" (from ")
-
+ + QDir::toNativeSeparators(platformPluginPath)
-
+ + QLatin1Char(')');
-
+ const QStringList::iterator end = list.end();
-
+ for (QStringList::iterator it = list.begin(); it != end; ++it)
-
+ (*it).append(postFix);
-
}
-
#else
-
Q_UNUSED(platformPluginPath);
+1 -2
pkgs/development/libraries/qt-5/5.8/qtbase/series
···
tzdir.patch
dlopen-libXcursor.patch
xdg-config-dirs.patch
-
nix-profiles-library-paths.patch
+
library-paths.patch
libressl.patch
-
qpa-platform-plugin-path.patch
dlopen-gl.patch
compose-search-path.patch
cmake-paths.patch
+6 -6
pkgs/development/libraries/qt-5/5.8/qtdeclarative/nix-profiles-import-paths.patch pkgs/development/libraries/qt-5/5.8/qtdeclarative/import-paths.patch
···
QString installImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
addImportPath(installImportsPath);
-
+ // Add library paths derived from NIX_PROFILES.
-
+ const QStringList profiles = QFile::decodeName(qgetenv("NIX_PROFILES")).split(' ');
-
+ const QString qmldir = QStringLiteral(NIXPKGS_QML2_IMPORT_PREFIX);
-
+ for (const QString &profile: profiles) {
-
+ if (!profile.isEmpty()) {
-
+ addImportPath(profile + QDir::separator() + qmldir);
+
+ // Add import paths derived from PATH
+
+ const QStringList paths = QFile::decodeName(qgetenv("PATH")).split(':');
+
+ const QString qmldir = QStringLiteral("../" NIXPKGS_QML2_IMPORT_PREFIX);
+
+ for (const QString &path: paths) {
+
+ if (!path.isEmpty()) {
+
+ addImportPath(QDir::cleanPath(path + QDir::separator() + qmldir));
+ }
+ }
+
+1 -1
pkgs/development/libraries/qt-5/5.8/qtdeclarative/series
···
-
nix-profiles-import-paths.patch
+
import-paths.patch