From a2e21c76c7d31d8f54a564c49ad3ef54d76fc1e4 Mon Sep 17 00:00:00 2001 From: linsui Date: Sat, 24 Dec 2022 17:59:15 +0800 Subject: rename config.qt5 -> config.qt --- .../doc/manual/configuration/x-windows.chapter.md | 6 +- .../from_md/configuration/x-windows.chapter.xml | 6 +- nixos/modules/config/qt.nix | 112 +++++++++++++++++++++ nixos/modules/config/qt5.nix | 106 ------------------- .../installation-cd-graphical-calamares-gnome.nix | 2 +- nixos/modules/module-list.nix | 2 +- .../services/x11/desktop-managers/cinnamon.nix | 8 +- .../services/x11/desktop-managers/gnome.nix | 4 +- .../services/x11/desktop-managers/pantheon.nix | 8 +- nixos/tests/keepassxc.nix | 2 +- 10 files changed, 131 insertions(+), 125 deletions(-) create mode 100644 nixos/modules/config/qt.nix delete mode 100644 nixos/modules/config/qt5.nix (limited to 'nixos') diff --git a/nixos/doc/manual/configuration/x-windows.chapter.md b/nixos/doc/manual/configuration/x-windows.chapter.md index f92403ed1c4c..be185cf4c314 100644 --- a/nixos/doc/manual/configuration/x-windows.chapter.md +++ b/nixos/doc/manual/configuration/x-windows.chapter.md @@ -199,9 +199,9 @@ GTK themes can be installed either to user profile or system-wide (via GTK ones, you can use the following configuration: ```nix -qt5.enable = true; -qt5.platformTheme = "gtk2"; -qt5.style = "gtk2"; +qt.enable = true; +qt.platformTheme = "gtk2"; +qt.style = "gtk2"; ``` ## Custom XKB layouts {#custom-xkb-layouts .unnumbered} diff --git a/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml b/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml index c5a8b9bae84d..319d3e980188 100644 --- a/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml +++ b/nixos/doc/manual/from_md/configuration/x-windows.chapter.xml @@ -223,9 +223,9 @@ services.xserver.libinput.touchpad.tapping = false; configuration: -qt5.enable = true; -qt5.platformTheme = "gtk2"; -qt5.style = "gtk2"; +qt.enable = true; +qt.platformTheme = "gtk2"; +qt.style = "gtk2";
diff --git a/nixos/modules/config/qt.nix b/nixos/modules/config/qt.nix new file mode 100644 index 000000000000..35defb8fbd99 --- /dev/null +++ b/nixos/modules/config/qt.nix @@ -0,0 +1,112 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.qt; + + isQGnome = cfg.platformTheme == "gnome" && builtins.elem cfg.style ["adwaita" "adwaita-dark"]; + isQtStyle = cfg.platformTheme == "gtk2" && !(builtins.elem cfg.style ["adwaita" "adwaita-dark"]); + isQt5ct = cfg.platformTheme == "qt5ct"; + isLxqt = cfg.platformTheme == "lxqt"; + isKde = cfg.platformTheme == "kde"; + + packages = + if isQGnome then [ + pkgs.qgnomeplatform + pkgs.adwaita-qt + pkgs.qgnomeplatform-qt6 + pkgs.adwaita-qt6 + ] + else if isQtStyle then [ pkgs.libsForQt5.qtstyleplugins ] + else if isQt5ct then [ pkgs.libsForQt5.qt5ct ] + else if isLxqt then [ pkgs.lxqt.lxqt-qtplugin pkgs.lxqt.lxqt-config ] + else if isKde then [ pkgs.libsForQt5.plasma-integration pkgs.libsForQt5.systemsettings ] + else throw "`qt.platformTheme` ${cfg.platformTheme} and `qt.style` ${cfg.style} are not compatible."; + +in + +{ + meta.maintainers = [ maintainers.romildo ]; + + imports = [ + (mkRenamedOptionModule ["qt5" "enable" ] ["qt" "enable" ]) + (mkRenamedOptionModule ["qt5" "platformTheme" ] ["qt" "platformTheme" ]) + (mkRenamedOptionModule ["qt5" "style" ] ["qt" "style" ]) + ]; + + options = { + qt = { + + enable = mkEnableOption (lib.mdDoc "Qt theming configuration"); + + platformTheme = mkOption { + type = types.enum [ + "gtk2" + "gnome" + "lxqt" + "qt5ct" + "kde" + ]; + example = "gnome"; + relatedPackages = [ + "qgnomeplatform" + "qgnomeplatform-qt6" + ["libsForQt5" "qtstyleplugins"] + ["libsForQt5" "qt5ct"] + ["lxqt" "lxqt-qtplugin"] + ["libsForQt5" "plasma-integration"] + ]; + description = lib.mdDoc '' + Selects the platform theme to use for Qt applications. + + The options are + - `gtk`: Use GTK theme with [qtstyleplugins](https://github.com/qt/qtstyleplugins) + - `gnome`: Use GNOME theme with [qgnomeplatform](https://github.com/FedoraQt/QGnomePlatform) + - `lxqt`: Use LXQt style set using the [lxqt-config-appearance](https://github.com/lxqt/lxqt-config) + application. + - `qt5ct`: Use Qt style set using the [qt5ct](https://sourceforge.net/projects/qt5ct/) + application. + - `kde`: Use Qt settings from Plasma. + ''; + }; + + style = mkOption { + type = types.enum [ + "adwaita" + "adwaita-dark" + "cleanlooks" + "gtk2" + "motif" + "plastique" + ]; + example = "adwaita"; + relatedPackages = [ + "adwaita-qt" + "adwaita-qt6" + ["libsForQt5" "qtstyleplugins"] + ]; + description = lib.mdDoc '' + Selects the style to use for Qt applications. + + The options are + - `adwaita`, `adwaita-dark`: Use Adwaita Qt style with + [adwaita](https://github.com/FedoraQt/adwaita-qt) + - `cleanlooks`, `gtk2`, `motif`, `plastique`: Use styles from + [qtstyleplugins](https://github.com/qt/qtstyleplugins) + ''; + }; + }; + }; + + config = mkIf cfg.enable { + + environment.variables.QT_QPA_PLATFORMTHEME = cfg.platformTheme; + + environment.variables.QT_STYLE_OVERRIDE = mkIf (! (isQt5ct || isLxqt || isKde)) cfg.style; + + environment.systemPackages = packages; + + }; +} diff --git a/nixos/modules/config/qt5.nix b/nixos/modules/config/qt5.nix deleted file mode 100644 index 7225388f99d2..000000000000 --- a/nixos/modules/config/qt5.nix +++ /dev/null @@ -1,106 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - - cfg = config.qt5; - - isQGnome = cfg.platformTheme == "gnome" && builtins.elem cfg.style ["adwaita" "adwaita-dark"]; - isQtStyle = cfg.platformTheme == "gtk2" && !(builtins.elem cfg.style ["adwaita" "adwaita-dark"]); - isQt5ct = cfg.platformTheme == "qt5ct"; - isLxqt = cfg.platformTheme == "lxqt"; - isKde = cfg.platformTheme == "kde"; - - packages = - if isQGnome then [ - pkgs.qgnomeplatform - pkgs.adwaita-qt - pkgs.qgnomeplatform-qt6 - pkgs.adwaita-qt6 - ] - else if isQtStyle then [ pkgs.libsForQt5.qtstyleplugins ] - else if isQt5ct then [ pkgs.libsForQt5.qt5ct ] - else if isLxqt then [ pkgs.lxqt.lxqt-qtplugin pkgs.lxqt.lxqt-config ] - else if isKde then [ pkgs.libsForQt5.plasma-integration pkgs.libsForQt5.systemsettings ] - else throw "`qt5.platformTheme` ${cfg.platformTheme} and `qt5.style` ${cfg.style} are not compatible."; - -in - -{ - meta.maintainers = [ maintainers.romildo ]; - - options = { - qt5 = { - - enable = mkEnableOption (lib.mdDoc "Qt5 theming configuration"); - - platformTheme = mkOption { - type = types.enum [ - "gtk2" - "gnome" - "lxqt" - "qt5ct" - "kde" - ]; - example = "gnome"; - relatedPackages = [ - "qgnomeplatform" - "qgnomeplatform-qt6" - ["libsForQt5" "qtstyleplugins"] - ["libsForQt5" "qt5ct"] - ["lxqt" "lxqt-qtplugin"] - ["libsForQt5" "plasma-integration"] - ]; - description = lib.mdDoc '' - Selects the platform theme to use for Qt5 applications. - - The options are - - `gtk`: Use GTK theme with [qtstyleplugins](https://github.com/qt/qtstyleplugins) - - `gnome`: Use GNOME theme with [qgnomeplatform](https://github.com/FedoraQt/QGnomePlatform) - - `lxqt`: Use LXQt style set using the [lxqt-config-appearance](https://github.com/lxqt/lxqt-config) - application. - - `qt5ct`: Use Qt style set using the [qt5ct](https://sourceforge.net/projects/qt5ct/) - application. - - `kde`: Use Qt settings from Plasma. - ''; - }; - - style = mkOption { - type = types.enum [ - "adwaita" - "adwaita-dark" - "cleanlooks" - "gtk2" - "motif" - "plastique" - ]; - example = "adwaita"; - relatedPackages = [ - "adwaita-qt" - "adwaita-qt6" - ["libsForQt5" "qtstyleplugins"] - ]; - description = lib.mdDoc '' - Selects the style to use for Qt5 applications. - - The options are - - `adwaita`, `adwaita-dark`: Use Adwaita Qt style with - [adwaita](https://github.com/FedoraQt/adwaita-qt) - - `cleanlooks`, `gtk2`, `motif`, `plastique`: Use styles from - [qtstyleplugins](https://github.com/qt/qtstyleplugins) - ''; - }; - }; - }; - - config = mkIf cfg.enable { - - environment.variables.QT_QPA_PLATFORMTHEME = cfg.platformTheme; - - environment.variables.QT_STYLE_OVERRIDE = mkIf (! (isQt5ct || isLxqt || isKde)) cfg.style; - - environment.systemPackages = packages; - - }; -} diff --git a/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix b/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix index d015e10c11d8..12feb2d96ecc 100644 --- a/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix +++ b/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares-gnome.nix @@ -31,7 +31,7 @@ }; # Theme calamares with GNOME theme - qt5 = { + qt = { enable = true; platformTheme = "gnome"; }; diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3092b021bd9a..adac3ac89bf8 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -20,7 +20,7 @@ ./config/nsswitch.nix ./config/power-management.nix ./config/pulseaudio.nix - ./config/qt5.nix + ./config/qt.nix ./config/resolvconf.nix ./config/shells-environment.nix ./config/swap.nix diff --git a/nixos/modules/services/x11/desktop-managers/cinnamon.nix b/nixos/modules/services/x11/desktop-managers/cinnamon.nix index df1b6f731a4e..a693f3e2379a 100644 --- a/nixos/modules/services/x11/desktop-managers/cinnamon.nix +++ b/nixos/modules/services/x11/desktop-managers/cinnamon.nix @@ -198,10 +198,10 @@ in programs.bash.vteIntegration = mkDefault true; programs.zsh.vteIntegration = mkDefault true; - # Harmonize Qt5 applications under Cinnamon - qt5.enable = true; - qt5.platformTheme = "gnome"; - qt5.style = "adwaita"; + # Harmonize Qt applications under Cinnamon + qt.enable = true; + qt.platformTheme = "gnome"; + qt.style = "adwaita"; # Default Fonts fonts.fonts = with pkgs; [ diff --git a/nixos/modules/services/x11/desktop-managers/gnome.nix b/nixos/modules/services/x11/desktop-managers/gnome.nix index 9c1978e362bc..dadfb421d3a8 100644 --- a/nixos/modules/services/x11/desktop-managers/gnome.nix +++ b/nixos/modules/services/x11/desktop-managers/gnome.nix @@ -352,8 +352,8 @@ in }) ]; - # Harmonize Qt5 application style and also make them use the portal for file chooser dialog. - qt5 = { + # Harmonize Qt application style and also make them use the portal for file chooser dialog. + qt = { enable = mkDefault true; platformTheme = mkDefault "gnome"; style = mkDefault "adwaita"; diff --git a/nixos/modules/services/x11/desktop-managers/pantheon.nix b/nixos/modules/services/x11/desktop-managers/pantheon.nix index 5c0203224e13..f5cc2d8187da 100644 --- a/nixos/modules/services/x11/desktop-managers/pantheon.nix +++ b/nixos/modules/services/x11/desktop-managers/pantheon.nix @@ -250,10 +250,10 @@ in programs.bash.vteIntegration = mkDefault true; programs.zsh.vteIntegration = mkDefault true; - # Harmonize Qt5 applications under Pantheon - qt5.enable = true; - qt5.platformTheme = "gnome"; - qt5.style = "adwaita"; + # Harmonize Qt applications under Pantheon + qt.enable = true; + qt.platformTheme = "gnome"; + qt.style = "adwaita"; # Default Fonts fonts.fonts = with pkgs; [ diff --git a/nixos/tests/keepassxc.nix b/nixos/tests/keepassxc.nix index 303be1330405..debb469032a6 100644 --- a/nixos/tests/keepassxc.nix +++ b/nixos/tests/keepassxc.nix @@ -17,7 +17,7 @@ import ./make-test-python.nix ({ pkgs, ...} : services.xserver.enable = true; # Regression test for https://github.com/NixOS/nixpkgs/issues/163482 - qt5 = { + qt = { enable = true; platformTheme = "gnome"; style = "adwaita-dark"; -- cgit v1.2.3