at 22.05-pre 3.1 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 12 packages = if isQGnome then [ pkgs.qgnomeplatform pkgs.adwaita-qt ] 13 else if isQtStyle then [ pkgs.libsForQt5.qtstyleplugins ] 14 else throw "`qt5.platformTheme` ${cfg.platformTheme} and `qt5.style` ${cfg.style} are not compatible."; 15 16in 17 18{ 19 20 options = { 21 qt5 = { 22 23 enable = mkEnableOption "Qt5 theming configuration"; 24 25 platformTheme = mkOption { 26 type = types.enum [ 27 "gtk2" 28 "gnome" 29 ]; 30 example = "gnome"; 31 relatedPackages = [ 32 "qgnomeplatform" 33 ["libsForQt5" "qtstyleplugins"] 34 ]; 35 description = '' 36 Selects the platform theme to use for Qt5 applications.</para> 37 <para>The options are 38 <variablelist> 39 <varlistentry> 40 <term><literal>gtk</literal></term> 41 <listitem><para>Use GTK theme with 42 <link xlink:href="https://github.com/qt/qtstyleplugins">qtstyleplugins</link> 43 </para></listitem> 44 </varlistentry> 45 <varlistentry> 46 <term><literal>gnome</literal></term> 47 <listitem><para>Use GNOME theme with 48 <link xlink:href="https://github.com/FedoraQt/QGnomePlatform">qgnomeplatform</link> 49 </para></listitem> 50 </varlistentry> 51 </variablelist> 52 ''; 53 }; 54 55 style = mkOption { 56 type = types.enum [ 57 "adwaita" 58 "adwaita-dark" 59 "cleanlooks" 60 "gtk2" 61 "motif" 62 "plastique" 63 ]; 64 example = "adwaita"; 65 relatedPackages = [ 66 "adwaita-qt" 67 ["libsForQt5" "qtstyleplugins"] 68 ]; 69 description = '' 70 Selects the style to use for Qt5 applications.</para> 71 <para>The options are 72 <variablelist> 73 <varlistentry> 74 <term><literal>adwaita</literal></term> 75 <term><literal>adwaita-dark</literal></term> 76 <listitem><para>Use Adwaita Qt style with 77 <link xlink:href="https://github.com/FedoraQt/adwaita-qt">adwaita</link> 78 </para></listitem> 79 </varlistentry> 80 <varlistentry> 81 <term><literal>cleanlooks</literal></term> 82 <term><literal>gtk2</literal></term> 83 <term><literal>motif</literal></term> 84 <term><literal>plastique</literal></term> 85 <listitem><para>Use styles from 86 <link xlink:href="https://github.com/qt/qtstyleplugins">qtstyleplugins</link> 87 </para></listitem> 88 </varlistentry> 89 </variablelist> 90 ''; 91 }; 92 }; 93 }; 94 95 config = mkIf cfg.enable { 96 97 environment.variables.QT_QPA_PLATFORMTHEME = cfg.platformTheme; 98 99 environment.variables.QT_STYLE_OVERRIDE = cfg.style; 100 101 environment.systemPackages = packages; 102 103 }; 104}