1 { config, lib, pkgs, ... }:
6 platformPackages = with pkgs; {
7 gnome = [ qgnomeplatform qgnomeplatform-qt6 ];
8 gtk2 = [ libsForQt5.qtstyleplugins qt6Packages.qt6gtk2 ];
9 kde = [ libsForQt5.plasma-integration libsForQt5.systemsettings ];
10 lxqt = [ lxqt.lxqt-qtplugin lxqt.lxqt-config ];
11 qt5ct = [ libsForQt5.qt5ct qt6Packages.qt6ct ];
14 stylePackages = with pkgs; {
15 bb10bright = [ libsForQt5.qtstyleplugins ];
16 bb10dark = [ libsForQt5.qtstyleplugins ];
17 cde = [ libsForQt5.qtstyleplugins ];
18 cleanlooks = [ libsForQt5.qtstyleplugins ];
19 gtk2 = [ libsForQt5.qtstyleplugins qt6Packages.qt6gtk2 ];
20 motif = [ libsForQt5.qtstyleplugins ];
21 plastique = [ libsForQt5.qtstyleplugins ];
23 adwaita = [ adwaita-qt adwaita-qt6 ];
24 adwaita-dark = [ adwaita-qt adwaita-qt6 ];
25 adwaita-highcontrast = [ adwaita-qt adwaita-qt6 ];
26 adwaita-highcontrastinverse = [ adwaita-qt adwaita-qt6 ];
28 breeze = [ libsForQt5.breeze-qt5 ];
30 kvantum = [ libsForQt5.qtstyleplugin-kvantum qt6Packages.qtstyleplugin-kvantum ];
34 meta.maintainers = with lib.maintainers; [ romildo thiagokokada ];
37 (lib.mkRenamedOptionModule [ "qt5" "enable" ] [ "qt" "enable" ])
38 (lib.mkRenamedOptionModule [ "qt5" "platformTheme" ] [ "qt" "platformTheme" ])
39 (lib.mkRenamedOptionModule [ "qt5" "style" ] [ "qt" "style" ])
44 enable = lib.mkEnableOption "" // {
46 Whether to enable Qt configuration, including theming.
48 Enabling this option is necessary for Qt plugins to work in the
49 installed profiles (e.g.: `nix-env -i` or `environment.systemPackages`).
53 platformTheme = lib.mkOption {
54 type = with lib.types; nullOr (enum (lib.attrNames platformPackages));
60 [ "libsForQt5" "plasma-integration" ]
61 [ "libsForQt5" "qt5ct" ]
62 [ "libsForQt5" "qtstyleplugins" ]
63 [ "libsForQt5" "systemsettings" ]
64 [ "lxqt" "lxqt-config" ]
65 [ "lxqt" "lxqt-qtplugin" ]
66 [ "qt6Packages" "qt6ct" ]
67 [ "qt6Packages" "qt6gtk2" ]
70 Selects the platform theme to use for Qt applications.
73 - `gnome`: Use GNOME theme with [qgnomeplatform](https://github.com/FedoraQt/QGnomePlatform)
74 - `gtk2`: Use GTK theme with [qtstyleplugins](https://github.com/qt/qtstyleplugins)
75 - `kde`: Use Qt settings from Plasma.
76 - `lxqt`: Use LXQt style set using the [lxqt-config-appearance](https://github.com/lxqt/lxqt-config)
78 - `qt5ct`: Use Qt style set using the [qt5ct](https://sourceforge.net/projects/qt5ct/)
79 and [qt6ct](https://github.com/trialuser02/qt6ct) applications.
83 style = lib.mkOption {
84 type = with lib.types; nullOr (enum (lib.attrNames stylePackages));
90 [ "libsForQt5" "breeze-qt5" ]
91 [ "libsForQt5" "qtstyleplugin-kvantum" ]
92 [ "libsForQt5" "qtstyleplugins" ]
93 [ "qt6Packages" "qt6gtk2" ]
94 [ "qt6Packages" "qtstyleplugin-kvantum" ]
97 Selects the style to use for Qt applications.
100 - `adwaita`, `adwaita-dark`, `adwaita-highcontrast`, `adawaita-highcontrastinverse`:
101 Use Adwaita Qt style with
102 [adwaita](https://github.com/FedoraQt/adwaita-qt)
103 - `breeze`: Use the Breeze style from
104 [breeze](https://github.com/KDE/breeze)
105 - `bb10bright`, `bb10dark`, `cleanlooks`, `gtk2`, `motif`, `plastique`:
107 [qtstyleplugins](https://github.com/qt/qtstyleplugins)
108 - `kvantum`: Use styles from
109 [kvantum](https://github.com/tsujan/Kvantum)
115 config = lib.mkIf cfg.enable {
121 "adwaita-highcontrast"
122 "adwaita-highcontrastinverse"
128 assertion = cfg.platformTheme == "gnome" -> (builtins.elem cfg.style gnomeStyles);
130 `qt.platformTheme` "gnome" must have `qt.style` set to a theme that supports both Qt and Gtk,
131 for example: ${lib.concatStringsSep ", " gnomeStyles}.
136 environment.variables = {
137 QT_QPA_PLATFORMTHEME = lib.mkIf (cfg.platformTheme != null) cfg.platformTheme;
138 QT_STYLE_OVERRIDE = lib.mkIf (cfg.style != null) cfg.style;
141 environment.profileRelativeSessionVariables =
143 qtVersions = with pkgs; [ qt5 qt6 ];
146 QT_PLUGIN_PATH = map (qt: "/${qt.qtbase.qtPluginPrefix}") qtVersions;
147 QML2_IMPORT_PATH = map (qt: "/${qt.qtbase.qtQmlPrefix}") qtVersions;
150 environment.systemPackages =
151 lib.optionals (cfg.platformTheme != null) (platformPackages.${cfg.platformTheme})
152 ++ lib.optionals (cfg.style != null) (stylePackages.${cfg.style});