diff --git a/modules/i18n/input-method/fcitx5.nix b/modules/i18n/input-method/fcitx5.nix index 1787a236..371f1cea 100644 --- a/modules/i18n/input-method/fcitx5.nix +++ b/modules/i18n/input-method/fcitx5.nix @@ -28,8 +28,9 @@ in { GTK_IM_MODULE = "fcitx"; QT_IM_MODULE = "fcitx"; XMODIFIERS = "@im=fcitx"; - QT_PLUGIN_PATH = - "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}:\${QT_PLUGIN_PATH}"; + # Using mkDefault here since we override this value in qt module if enabled + QT_PLUGIN_PATH = lib.mkDefault + "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}"; }; systemd.user.services.fcitx5-daemon = { diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index e50f416a..a5a4f163 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -130,6 +130,7 @@ in { envVars = let inherit (config.home) profileDirectory; qtVersions = with pkgs; [ qt5 qt6 ]; + makeQtPath = prefix: basePath: qt: "${basePath}/${qt.qtbase.${prefix}}"; in lib.filterAttrs (n: v: v != null) { QT_QPA_PLATFORMTHEME = if cfg.platformTheme == "gtk" then "gtk2" @@ -140,12 +141,15 @@ in { QT_STYLE_OVERRIDE = cfg.style.name; QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}" + (lib.concatStringsSep ":" - (map (qt: "${profileDirectory}/${qt.qtbase.qtPluginPrefix}") - qtVersions)); + # Workaround issue with home.sessionVariables that does not support + # multiple different values since fcitx5 also needs to set QT_PLUGIN_PATH. + (lib.optional (config.i18n.inputMethod == "fcitx5") + (makeQtPath "qtPluginPrefix" config.i18n.inputMethod.package + pkgs.qt6) ++ (map (makeQtPath "qtPluginPrefix" profileDirectory) + qtVersions))); QML2_IMPORT_PATH = "$QML2_IMPORT_PATH\${QML2_IMPORT_PATH:+:}" + (lib.concatStringsSep ":" - (map (qt: "${profileDirectory}/${qt.qtbase.qtQmlPrefix}") - qtVersions)); + (map (makeQtPath "qtQmlPrefix" profileDirectory) qtVersions)); }; in lib.mkIf (cfg.enable && cfg.platformTheme != null) { diff --git a/tests/modules/misc/qt/qt-platform-theme-gtk.nix b/tests/modules/misc/qt/qt-platform-theme-gtk.nix index b91496b5..070c8020 100644 --- a/tests/modules/misc/qt/qt-platform-theme-gtk.nix +++ b/tests/modules/misc/qt/qt-platform-theme-gtk.nix @@ -6,6 +6,7 @@ enable = true; platformTheme = "gtk"; }; + i18n.inputMethod.enabled = "fcitx5"; nmt.script = '' assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \