From 2e44116afcd1a80bd68d9a8e0b554271a9ad37c8 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Wed, 18 Oct 2023 12:54:36 +0100 Subject: [PATCH] qt: export QT_PLUGIN_PATH/QML2_IMPORT_PATH Those 2 variables are necessary to make e.g.: qt6ct work correctly. See issue: https://github.com/NixOS/nixpkgs/issues/239909. --- modules/misc/qt.nix | 16 ++++++++++++++-- .../modules/misc/qt/qt-platform-theme-gnome.nix | 4 ++++ tests/modules/misc/qt/qt-platform-theme-gtk.nix | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index 314a4a2c5..e78a8aca7 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -127,7 +127,10 @@ in { config = let # Necessary because home.sessionVariables doesn't support mkIf - envVars = filterAttrs (n: v: v != null) { + envVars = let + inherit (config.home) profileDirectory; + qtVersions = with pkgs; [ qt5 qt6 ]; + in filterAttrs (n: v: v != null) { QT_QPA_PLATFORMTHEME = if cfg.platformTheme == "gtk" then "gtk2" else if cfg.platformTheme == "qtct" then @@ -135,6 +138,14 @@ in { else cfg.platformTheme; QT_STYLE_OVERRIDE = cfg.style.name; + QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}" + + (lib.concatStringsSep ":" + (map (qt: "${profileDirectory}/${qt.qtbase.qtPluginPrefix}") + qtVersions)); + QML2_IMPORT_PATH = "$QML2_IMPORT_PATH\${QML2_IMPORT_PATH:+:}" + + (lib.concatStringsSep ":" + (map (qt: "${profileDirectory}/${qt.qtbase.qtQmlPrefix}") + qtVersions)); }; in mkIf (cfg.enable && cfg.platformTheme != null) { @@ -168,7 +179,8 @@ in { ++ lib.optionals (cfg.style.package != null) (lib.toList cfg.style.package); - xsession.importedVariables = [ "QT_QPA_PLATFORMTHEME" ] + xsession.importedVariables = + [ "QT_QPA_PLATFORMTHEME" "QT_PLUGIN_PATH" "QML2_IMPORT_PATH" ] ++ lib.optionals (cfg.style.name != null) [ "QT_STYLE_OVERRIDE" ]; }; } diff --git a/tests/modules/misc/qt/qt-platform-theme-gnome.nix b/tests/modules/misc/qt/qt-platform-theme-gnome.nix index 58b4cd7a1..d95ef704a 100644 --- a/tests/modules/misc/qt/qt-platform-theme-gnome.nix +++ b/tests/modules/misc/qt/qt-platform-theme-gnome.nix @@ -15,6 +15,10 @@ 'QT_QPA_PLATFORMTHEME="gnome"' assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ 'QT_STYLE_OVERRIDE="adwaita"' + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'QT_PLUGIN_PATH' + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'QML2_IMPORT_PATH' ''; }; } diff --git a/tests/modules/misc/qt/qt-platform-theme-gtk.nix b/tests/modules/misc/qt/qt-platform-theme-gtk.nix index d33246528..b91496b5a 100644 --- a/tests/modules/misc/qt/qt-platform-theme-gtk.nix +++ b/tests/modules/misc/qt/qt-platform-theme-gtk.nix @@ -10,6 +10,10 @@ nmt.script = '' assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ 'QT_QPA_PLATFORMTHEME="gtk2"' + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'QT_PLUGIN_PATH' + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'QML2_IMPORT_PATH' ''; }; }