mirror of
https://github.com/nix-community/home-manager
synced 2024-12-26 03:39:47 +01:00
qt: use sessionVariablesExtra to export QT_PLUGIN_PATH/QML2_IMPORT_PATH
This commit is contained in:
parent
418475f3b9
commit
93883c4bd9
2 changed files with 26 additions and 18 deletions
|
@ -28,8 +28,7 @@ in {
|
||||||
GTK_IM_MODULE = "fcitx";
|
GTK_IM_MODULE = "fcitx";
|
||||||
QT_IM_MODULE = "fcitx";
|
QT_IM_MODULE = "fcitx";
|
||||||
XMODIFIERS = "@im=fcitx";
|
XMODIFIERS = "@im=fcitx";
|
||||||
# Using mkDefault here since we override this value in qt module if enabled
|
QT_PLUGIN_PATH =
|
||||||
QT_PLUGIN_PATH = lib.mkDefault
|
|
||||||
"$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}";
|
"$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -154,25 +154,23 @@ in {
|
||||||
config = let
|
config = let
|
||||||
|
|
||||||
# Necessary because home.sessionVariables doesn't support mkIf
|
# Necessary because home.sessionVariables doesn't support mkIf
|
||||||
envVars = let
|
envVars = lib.filterAttrs (n: v: v != null) {
|
||||||
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 =
|
QT_QPA_PLATFORMTHEME =
|
||||||
styleNames.${cfg.platformTheme} or cfg.platformTheme;
|
styleNames.${cfg.platformTheme} or cfg.platformTheme;
|
||||||
QT_STYLE_OVERRIDE = cfg.style.name;
|
QT_STYLE_OVERRIDE = cfg.style.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
envVarsExtra = let
|
||||||
|
inherit (config.home) profileDirectory;
|
||||||
|
qtVersions = with pkgs; [ qt5 qt6 ];
|
||||||
|
makeQtPath = prefix:
|
||||||
|
lib.concatStringsSep ":"
|
||||||
|
(map (qt: "${profileDirectory}/${qt.qtbase.${prefix}}") qtVersions);
|
||||||
|
in {
|
||||||
QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}"
|
QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}"
|
||||||
+ (lib.concatStringsSep ":"
|
+ (makeQtPath "qtPluginPrefix");
|
||||||
# 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:+:}"
|
QML2_IMPORT_PATH = "$QML2_IMPORT_PATH\${QML2_IMPORT_PATH:+:}"
|
||||||
+ (lib.concatStringsSep ":"
|
+ (makeQtPath "qtQmlPrefix");
|
||||||
(map (makeQtPath "qtQmlPrefix" profileDirectory) qtVersions));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
in lib.mkIf (cfg.enable && cfg.platformTheme != null) {
|
in lib.mkIf (cfg.enable && cfg.platformTheme != null) {
|
||||||
|
@ -188,10 +186,21 @@ in {
|
||||||
qt.style.package = lib.mkIf (cfg.style.name != null)
|
qt.style.package = lib.mkIf (cfg.style.name != null)
|
||||||
(lib.mkDefault (stylePackages.${lib.toLower cfg.style.name} or null));
|
(lib.mkDefault (stylePackages.${lib.toLower cfg.style.name} or null));
|
||||||
|
|
||||||
home.sessionVariables = envVars;
|
home = {
|
||||||
|
sessionVariables = envVars;
|
||||||
|
# home.sessionVariables does not support setting the same environment
|
||||||
|
# variable to different values.
|
||||||
|
# Since some other modules may set the QT_PLUGIN_PATH or QML2_IMPORT_PATH
|
||||||
|
# to their own value, e.g.: fcitx5, we avoid conflicts by setting
|
||||||
|
# the values in home.sessionVariablesExtra instead.
|
||||||
|
sessionVariablesExtra = ''
|
||||||
|
export QT_PLUGIN_PATH=${envVarsExtra.QT_PLUGIN_PATH}
|
||||||
|
export QML2_IMPORT_PATH=${envVarsExtra.QML2_IMPORT_PATH}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# Apply theming also to apps started by systemd.
|
# Apply theming also to apps started by systemd.
|
||||||
systemd.user.sessionVariables = envVars;
|
systemd.user.sessionVariables = envVars // envVarsExtra;
|
||||||
|
|
||||||
home.packages = (platformPackages.${cfg.platformTheme} or [ ])
|
home.packages = (platformPackages.${cfg.platformTheme} or [ ])
|
||||||
++ lib.optionals (cfg.style.package != null)
|
++ lib.optionals (cfg.style.package != null)
|
||||||
|
|
Loading…
Reference in a new issue