git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #66392 from worldofpeace/qt-theme/module

nixos/qt5: init

commitfd7fa0aa5dc03958d1d0f4f45fc2e91567e04254 authorworldofpeace <worldofpeace@protonmail.ch> dateTue 20 Aug 2019, 12:44 (7 years ago) parent5d3b5451d0d69a
2 files changed+103
nixos/modules/config/qt5.nix+102 nixos/modules/module-list.nix+1
nixos/modules/config/qt5.nixnew file+102
@@ -0,0 +1,102 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+
7+ cfg = config.qt5;
8+
9+ isQGnome = cfg.platformTheme == "gnome" && cfg.style == "adwaita";
10+ isQtStyle = cfg.platformTheme == "gtk2" && cfg.style != "adwaita";
11+
12+ packages = if isQGnome then [ pkgs.qgnomeplatform pkgs.adwaita-qt ]
13+ else if isQtStyle then [ pkgs.qtstyleplugins ]
14+ else throw "`qt5.platformTheme` ${cfg.platformTheme} and `qt5.style` ${cfg.style} are not compatible.";
15+
16+in
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+ "cleanlooks"
59+ "gtk2"
60+ "motif"
61+ "plastique"
62+ ];
63+ example = "adwaita";
64+ relatedPackages = [
65+ "adwaita-qt"
66+ ["libsForQt5" "qtstyleplugins"]
67+ ];
68+ description = ''
69+ Selects the style to use for Qt5 applications.</para>
70+ <para>The options are
71+ <variablelist>
72+ <varlistentry>
73+ <term><literal>adwaita</literal></term>
74+ <listitem><para>Use Adwaita Qt style with
75+ <link xlink:href="https://github.com/FedoraQt/adwaita-qt">adwaita</link>
76+ </para></listitem>
77+ </varlistentry>
78+ <varlistentry>
79+ <term><literal>cleanlooks</literal></term>
80+ <term><literal>gtk2</literal></term>
81+ <term><literal>motif</literal></term>
82+ <term><literal>plastique</literal></term>
83+ <listitem><para>Use styles from
84+ <link xlink:href="https://github.com/qt/qtstyleplugins">qtstyleplugins</link>
85+ </para></listitem>
86+ </varlistentry>
87+ </variablelist>
88+ '';
89+ };
90+ };
91+ };
92+
93+ config = mkIf cfg.enable {
94+
95+ environment.variables.QT_QPA_PLATFORMTHEME = cfg.platformTheme;
96+
97+ environment.variables.QT_STYLE_OVERRIDE = cfg.style;
98+
99+ environment.systemPackages = packages;
100+
101+ };
102+}
nixos/modules/module-list.nix+1
@@ -27,6 +27,7 @@
2727 ./config/nsswitch.nix
2828 ./config/power-management.nix
2929 ./config/pulseaudio.nix
30+ ./config/qt5.nix
3031 ./config/resolvconf.nix
3132 ./config/shells-environment.nix
3233 ./config/swap.nix