diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index 314a4a2c..e78a8aca 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 58b4cd7a..d95ef704 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 d3324652..b91496b5 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' ''; }; }