From fff5204e5dbe8403d5ad1816c183f7b663d9fe1d Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 19 Nov 2023 12:35:28 +0000 Subject: [PATCH 1/2] qt: fix basic usage when just `qt.enable = true` is set --- modules/misc/qt.nix | 13 ++++++++----- tests/modules/misc/qt/default.nix | 1 + tests/modules/misc/qt/qt-basic.nix | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 tests/modules/misc/qt/qt-basic.nix diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index 495841ea4..90fdd140c 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -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" ] diff --git a/tests/modules/misc/qt/default.nix b/tests/modules/misc/qt/default.nix index c676b784e..44b6b96ca 100644 --- a/tests/modules/misc/qt/default.nix +++ b/tests/modules/misc/qt/default.nix @@ -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; } diff --git a/tests/modules/misc/qt/qt-basic.nix b/tests/modules/misc/qt/qt-basic.nix new file mode 100644 index 000000000..9ddddb357 --- /dev/null +++ b/tests/modules/misc/qt/qt-basic.nix @@ -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' + ''; + }; +} From 3de857fa7d996a60966cccb44fbfce8d3c4544d8 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Mon, 20 Nov 2023 20:33:29 +0000 Subject: [PATCH 2/2] qt: fix `qt.platformTheme = "gtk3"` --- modules/misc/qt.nix | 2 +- tests/modules/misc/qt/default.nix | 1 + .../misc/qt/qt-platform-theme-gtk3.nix | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/modules/misc/qt/qt-platform-theme-gtk3.nix diff --git a/modules/misc/qt.nix b/modules/misc/qt.nix index 90fdd140c..f02bc186e 100644 --- a/modules/misc/qt.nix +++ b/modules/misc/qt.nix @@ -209,7 +209,7 @@ in { systemd.user.sessionVariables = envVars // envVarsExtra; home.packages = (lib.optionals (cfg.platformTheme != null) - platformPackages.${cfg.platformTheme}) + platformPackages.${cfg.platformTheme} or [ ]) ++ (lib.optionals (cfg.style.package != null) (lib.toList cfg.style.package)); diff --git a/tests/modules/misc/qt/default.nix b/tests/modules/misc/qt/default.nix index 44b6b96ca..da27bf31f 100644 --- a/tests/modules/misc/qt/default.nix +++ b/tests/modules/misc/qt/default.nix @@ -1,5 +1,6 @@ { qt-basic = ./qt-basic.nix; qt-platform-theme-gtk = ./qt-platform-theme-gtk.nix; + qt-platform-theme-gtk3 = ./qt-platform-theme-gtk3.nix; qt-platform-theme-gnome = ./qt-platform-theme-gnome.nix; } diff --git a/tests/modules/misc/qt/qt-platform-theme-gtk3.nix b/tests/modules/misc/qt/qt-platform-theme-gtk3.nix new file mode 100644 index 000000000..2b3ade9dd --- /dev/null +++ b/tests/modules/misc/qt/qt-platform-theme-gtk3.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +{ + config = { + qt = { + enable = true; + platformTheme = "gtk3"; + }; + + nmt.script = '' + assertFileRegex home-path/etc/profile.d/hm-session-vars.sh \ + 'QT_QPA_PLATFORMTHEME="gtk3"' + 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' + ''; + }; +}