python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / modules / config / qt5.nix
blobcb3180d7b96a567aaecb0d35376aca7528912ec6
1 { config, lib, pkgs, ... }:
3 with lib;
5 let
7   cfg = config.qt5;
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 ];
27   options = {
28     qt5 = {
30       enable = mkEnableOption (lib.mdDoc "Qt5 theming configuration");
32       platformTheme = mkOption {
33         type = types.enum [
34           "gtk2"
35           "gnome"
36           "lxqt"
37           "qt5ct"
38           "kde"
39         ];
40         example = "gnome";
41         relatedPackages = [
42           "qgnomeplatform"
43           ["libsForQt5" "qtstyleplugins"]
44           ["libsForQt5" "qt5ct"]
45           ["lxqt" "lxqt-qtplugin"]
46           ["libsForQt5" "plasma-integration"]
47         ];
48         description = lib.mdDoc ''
49           Selects the platform theme to use for Qt5 applications.
51           The options are
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)
55              application.
56           - `qt5ct`: Use Qt style set using the [qt5ct](https://sourceforge.net/projects/qt5ct/)
57              application.
58           - `kde`: Use Qt settings from Plasma.
59         '';
60       };
62       style = mkOption {
63         type = types.enum [
64           "adwaita"
65           "adwaita-dark"
66           "cleanlooks"
67           "gtk2"
68           "motif"
69           "plastique"
70         ];
71         example = "adwaita";
72         relatedPackages = [
73           "adwaita-qt"
74           ["libsForQt5" "qtstyleplugins"]
75         ];
76         description = lib.mdDoc ''
77           Selects the style to use for Qt5 applications.
79           The options are
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)
84         '';
85       };
86     };
87   };
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;
97   };