1 { config, lib, pkgs, ... }:
9 isQGnome = cfg.platformTheme == "gnome" && builtins.elem cfg.style ["adwaita" "adwaita-dark"];
10 isQtStyle = cfg.platformTheme == "gtk2" && !(builtins.elem cfg.style ["adwaita" "adwaita-dark"]);
11 isQt5ct = cfg.platformTheme == "qt5ct";
12 isLxqt = cfg.platformTheme == "lxqt";
13 isKde = cfg.platformTheme == "kde";
15 packages = if isQGnome then [ pkgs.qgnomeplatform pkgs.adwaita-qt ]
16 else if isQtStyle then [ pkgs.libsForQt5.qtstyleplugins ]
17 else if isQt5ct then [ pkgs.libsForQt5.qt5ct ]
18 else if isLxqt then [ pkgs.lxqt.lxqt-qtplugin pkgs.lxqt.lxqt-config ]
19 else if isKde then [ pkgs.libsForQt5.plasma-integration pkgs.libsForQt5.systemsettings ]
20 else throw "`qt5.platformTheme` ${cfg.platformTheme} and `qt5.style` ${cfg.style} are not compatible.";
25 meta.maintainers = [ maintainers.romildo ];
30 enable = mkEnableOption (lib.mdDoc "Qt5 theming configuration");
32 platformTheme = mkOption {
43 ["libsForQt5" "qtstyleplugins"]
44 ["libsForQt5" "qt5ct"]
45 ["lxqt" "lxqt-qtplugin"]
46 ["libsForQt5" "plasma-integration"]
48 description = lib.mdDoc ''
49 Selects the platform theme to use for Qt5 applications.
52 - `gtk`: Use GTK theme with [qtstyleplugins](https://github.com/qt/qtstyleplugins)
53 - `gnome`: Use GNOME theme with [qgnomeplatform](https://github.com/FedoraQt/QGnomePlatform)
54 - `lxqt`: Use LXQt style set using the [lxqt-config-appearance](https://github.com/lxqt/lxqt-config)
56 - `qt5ct`: Use Qt style set using the [qt5ct](https://sourceforge.net/projects/qt5ct/)
58 - `kde`: Use Qt settings from Plasma.
74 ["libsForQt5" "qtstyleplugins"]
76 description = lib.mdDoc ''
77 Selects the style to use for Qt5 applications.
80 - `adwaita`, `adwaita-dark`: Use Adwaita Qt style with
81 [adwaita](https://github.com/FedoraQt/adwaita-qt)
82 - `cleanlooks`, `gtk2`, `motif`, `plastique`: Use styles from
83 [qtstyleplugins](https://github.com/qt/qtstyleplugins)
89 config = mkIf cfg.enable {
91 environment.variables.QT_QPA_PLATFORMTHEME = cfg.platformTheme;
93 environment.variables.QT_STYLE_OVERRIDE = mkIf (! (isQt5ct || isLxqt || isKde)) cfg.style;
95 environment.systemPackages = packages;