qt: fix basic usage when just qt.enable = true is set

This commit is contained in:
Thiago Kenji Okada 2023-11-19 12:35:28 +00:00
parent 9a4725afa6
commit fff5204e5d
3 changed files with 23 additions and 5 deletions

View file

@ -159,8 +159,10 @@ in {
# Necessary because home.sessionVariables doesn't support mkIf
envVars = lib.filterAttrs (n: v: v != null) {
QT_QPA_PLATFORMTHEME =
styleNames.${cfg.platformTheme} or cfg.platformTheme;
QT_QPA_PLATFORMTHEME = if (cfg.platformTheme != null) then
styleNames.${cfg.platformTheme} or cfg.platformTheme
else
null;
QT_STYLE_OVERRIDE = cfg.style.name;
};
@ -206,9 +208,10 @@ in {
# Apply theming also to apps started by systemd.
systemd.user.sessionVariables = envVars // envVarsExtra;
home.packages = (platformPackages.${cfg.platformTheme} or [ ])
++ lib.optionals (cfg.style.package != null)
(lib.toList cfg.style.package);
home.packages = (lib.optionals (cfg.platformTheme != null)
platformPackages.${cfg.platformTheme})
++ (lib.optionals (cfg.style.package != null)
(lib.toList cfg.style.package));
xsession.importedVariables = [ "QT_PLUGIN_PATH" "QML2_IMPORT_PATH" ]
++ lib.optionals (cfg.platformTheme != null) [ "QT_QPA_PLATFORMTHEME" ]

View file

@ -1,4 +1,5 @@
{
qt-basic = ./qt-basic.nix;
qt-platform-theme-gtk = ./qt-platform-theme-gtk.nix;
qt-platform-theme-gnome = ./qt-platform-theme-gnome.nix;
}

View file

@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
{
config = {
qt.enable = true;
nmt.script = ''
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'
'';
};
}