at 23.05-pre 3.0 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.qt5; 8 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"; 14 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."; 21 22in 23 24{ 25 meta.maintainers = [ maintainers.romildo ]; 26 27 options = { 28 qt5 = { 29 30 enable = mkEnableOption (lib.mdDoc "Qt5 theming configuration"); 31 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. 50 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 }; 61 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. 78 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 }; 88 89 config = mkIf cfg.enable { 90 91 environment.variables.QT_QPA_PLATFORMTHEME = cfg.platformTheme; 92 93 environment.variables.QT_STYLE_OVERRIDE = mkIf (! (isQt5ct || isLxqt || isKde)) cfg.style; 94 95 environment.systemPackages = packages; 96 97 }; 98}