aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/home-manager/modules/misc/qt.nix
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/home-manager/modules/misc/qt.nix')
-rw-r--r--infra/libkookie/home-manager/modules/misc/qt.nix59
1 files changed, 56 insertions, 3 deletions
diff --git a/infra/libkookie/home-manager/modules/misc/qt.nix b/infra/libkookie/home-manager/modules/misc/qt.nix
index ff38f842c810..1fdaf9f9b949 100644
--- a/infra/libkookie/home-manager/modules/misc/qt.nix
+++ b/infra/libkookie/home-manager/modules/misc/qt.nix
@@ -44,19 +44,72 @@ in {
</variablelist>
'';
};
+
+ style = {
+ name = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = "adwaita-dark";
+ relatedPackages = [ "adwaita-qt" [ "libsForQt5" "qtstyleplugins" ] ];
+ description = ''
+ Selects the style to use for Qt5 applications.</para>
+ <para>The options are
+ <variablelist>
+ <varlistentry>
+ <term><literal>adwaita</literal></term>
+ <term><literal>adwaita-dark</literal></term>
+ <listitem><para>Use Adwaita Qt style with
+ <link xlink:href="https://github.com/FedoraQt/adwaita-qt">adwaita</link>
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><literal>cleanlooks</literal></term>
+ <term><literal>gtk2</literal></term>
+ <term><literal>motif</literal></term>
+ <term><literal>plastique</literal></term>
+ <listitem><para>Use styles from
+ <link xlink:href="https://github.com/qt/qtstyleplugins">qtstyleplugins</link>
+ </para></listitem>
+ </varlistentry>
+ </variablelist>
+ '';
+ };
+
+ package = mkOption {
+ type = types.nullOr types.package;
+ default = null;
+ example = literalExample "pkgs.adwaita-qt";
+ description = "Theme package to be used in Qt5 applications.";
+ };
+ };
};
};
config = mkIf (cfg.enable && cfg.platformTheme != null) {
- home.sessionVariables.QT_QPA_PLATFORMTHEME =
- if cfg.platformTheme == "gnome" then "gnome" else "gtk2";
+ assertions = [{
+ assertion = (cfg.platformTheme == "gnome")
+ -> ((cfg.style.name != null) && (cfg.style.package != null));
+ message = ''
+ `qt.platformTheme` "gnome" must have `qt.style` set to a theme that
+ supports both Qt and Gtk, for example "adwaita" or "adwaita-dark".
+ '';
+ }];
+
+ # Necessary because home.sessionVariables is of types.attrs
+ home.sessionVariables = (filterAttrs (n: v: v != null) {
+ QT_QPA_PLATFORMTHEME =
+ if cfg.platformTheme == "gnome" then "gnome" else "gtk2";
+ QT_STYLE_OVERRIDE = cfg.style.name;
+ });
home.packages = if cfg.platformTheme == "gnome" then
[ pkgs.qgnomeplatform ]
+ ++ lib.optionals (cfg.style.package != null) [ cfg.style.package ]
else
[ pkgs.libsForQt5.qtstyleplugins ];
- xsession.importedVariables = [ "QT_QPA_PLATFORMTHEME" ];
+ xsession.importedVariables = [ "QT_QPA_PLATFORMTHEME" ]
+ ++ lib.optionals (cfg.style != null) [ "QT_STYLE_OVERRIDE" ];
# Enable GTK+ style for Qt4 in either case.
# It doesn’t support the platform theme packages.