1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 19:29:47 +01:00

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.
This commit is contained in:
Thiago Kenji Okada 2023-10-18 12:54:36 +01:00 committed by Mikilio
parent c7ac0e0d36
commit 2e44116afc
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
3 changed files with 22 additions and 2 deletions

View file

@ -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" ];
};
}

View file

@ -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'
'';
};
}

View file

@ -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'
'';
};
}