From 193e2ed86ea122b288ff8a616512bf821656ac47 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Sat, 12 Oct 2019 14:18:00 +0300 Subject: nixos/gtk: init --- nixos/modules/module-list.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'nixos/modules/module-list.nix') diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 878b77969af1..101c235e63f4 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -13,6 +13,7 @@ ./config/appstream.nix ./config/console.nix ./config/xdg/sounds.nix + ./config/gtk/gtk.nix ./config/gtk/gtk-icon-cache.nix ./config/gnu.nix ./config/i18n.nix -- cgit 1.4.1 From 1bd7ea84ad7e2bb4643ecf0f62e376aeb05ad7be Mon Sep 17 00:00:00 2001 From: gnidorah Date: Sun, 13 Oct 2019 08:55:36 +0300 Subject: nixos/qt5: rename to qt --- nixos/modules/config/qt.nix | 240 +++++++++++++++++++++ nixos/modules/config/qt5.nix | 232 -------------------- nixos/modules/module-list.nix | 2 +- .../services/x11/desktop-managers/pantheon.nix | 6 +- 4 files changed, 244 insertions(+), 236 deletions(-) create mode 100644 nixos/modules/config/qt.nix delete mode 100644 nixos/modules/config/qt5.nix (limited to 'nixos/modules/module-list.nix') diff --git a/nixos/modules/config/qt.nix b/nixos/modules/config/qt.nix new file mode 100644 index 000000000000..a145eaab4f1a --- /dev/null +++ b/nixos/modules/config/qt.nix @@ -0,0 +1,240 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.qt; + + toQtIni = generators.toINI { + mkKeyValue = key: value: + let + value' = + if isBool value then (if value then "true" else "false") + else toString value; + in + "${key}=${value'}"; + }; + + general = + optionalAttrs (cfg.font != null) + { + font = cfg.font.name; + menuFont = cfg.font.name; + toolBarFont = cfg.font.name; + } + // + optionalAttrs (cfg.style != null) + { widgetStyle = cfg.style.name; }; + icons = + optionalAttrs (cfg.iconTheme != null) + { Theme = cfg.iconTheme.name; }; + + fontType = types.submodule { + options = { + package = mkOption { + internal = true; + type = types.nullOr types.package; + default = null; + }; + name = mkOption { + internal = true; + type = types.str; + }; + }; + }; + themeType = types.submodule { + options = { + package = mkOption { + internal = true; + type = types.nullOr types.package; + default = null; + }; + name = mkOption { + internal = true; + type = types.str; + }; + }; + }; + + optionalPackage = opt: + optional (opt != null && opt.package != null) opt.package; + + platforms = { + gtk2 = rec { + description = '' + + gtk2 + Use GTK2 theme with + qtstyleplugins + + + ''; + styles = [ "cleanlooks" "gtk2" "cde" "motif" "plastique" ]; + + assertions = [ + { + assertion = cfg.style != null && any (name: name == cfg.style.name) styles; + message = "`qt5.style.name` is not one of [ ${toString styles} ]."; + } + { + assertion = cfg.font == null && cfg.iconTheme == null; + message = "`qt.font` and `qt.iconTheme` are only supported by kde platform."; + } + ]; + environment.variables.QT_QPA_PLATFORMTHEME = "gtk2"; + environment.variables.QT_STYLE_OVERRIDE = cfg.style.name; + environment.systemPackages = [ pkgs.libsForQt5.qtstyleplugins ]; + }; + qgnomeplatform = { + description = '' + + qgnomeplatform + Use GNOME theme with + qgnomeplatform + + + ''; + + assertions = [ + { + assertion = cfg.font == null && cfg.iconTheme == null; + message = "`qt.font` and `qt.iconTheme` are only supported by kde platform."; + } + ]; + environment.variables.QT_QPA_PLATFORMTHEME = "qgnomeplatform"; + # TODO: make this optional once https://github.com/NixOS/nixpkgs/issues/54150 is fixed + # qgnomeplatform reads theme and other settings from dconf db + environment.variables.QT_STYLE_OVERRIDE = cfg.style.name; + environment.variables.XDG_DATA_DIRS = [ "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}" ]; + environment.systemPackages = [ pkgs.qgnomeplatform ]; + }; + gtk3 = { + description = '' + + gtk3 + Use GNOME theme with + gtk3 + + + ''; + + assertions = [ + { + assertion = cfg.style != null; + message = "`qt5.platformTheme` gtk3 requires `qt5.style` to be set."; + } + { + assertion = cfg.font == null && cfg.iconTheme == null; + message = "`qt.font` and `qt.iconTheme` are only supported by kde platform."; + } + ]; + environment.variables.QT_QPA_PLATFORMTHEME = "gtk3"; + environment.variables.QT_STYLE_OVERRIDE = cfg.style.name; + }; + kde = { + description = '' + + kde + Use Qt theme with + qkdetheme + + + ''; + + environment.variables.XDG_CURRENT_DESKTOP = mkForce "KDE"; + environment.variables.KDE_SESSION_VERSION = "5"; + environment.etc."xdg/kdeglobals".text = + toQtIni { + General = general; + Icons = icons; + }; + }; + }; +in + +{ + + imports = [ + (mkRenamedOptionModule [ "qt5" "style" ] [ "qt" "style" ]) + (mkRenamedOptionModule [ "qt5" "enable" ] [ "qt" "enable" ]) + (mkRenamedOptionModule [ "qt5" "platformTheme" ] [ "qt" "platformTheme" ]) + (mkRenamedOptionModule [ "qt5" "font" ] [ "qt" "font" ]) + (mkRenamedOptionModule [ "qt5" "iconTheme" ] [ "qt" "iconTheme" ]) + ]; + + options = { + qt = { + + enable = mkEnableOption "Qt theming configuration"; + + platformTheme = mkOption { + type = types.enum (attrNames platforms); + example = head (attrNames platforms); + description = '' + Selects the platform theme to use for Qt applications. + The options are + + ${concatStrings (mapAttrsToList (name: value: value.description) platforms)} + + ''; + }; + + font = mkOption { + type = types.nullOr fontType; + default = null; + example = literalExample '' + { + name = "Noto Sans,10,-1,5,50,0,0,0,0,0,Regular"; + package = pkgs.noto-fonts; + } + ''; + description = '' + The font to use in Qt applications. + ''; + }; + + iconTheme = mkOption { + type = types.nullOr themeType; + default = null; + example = literalExample '' + { + name = "breeze"; + package = pkgs.breeze-icons; + } + ''; + description = "The icon theme to use."; + }; + + style = mkOption { + type = types.nullOr themeType; + default = null; + example = literalExample '' + { + name = "Breeze"; + package = pkgs.breeze-qt5; + }; + ''; + description = "The Qt style to use."; + }; + + }; + }; + + config = mkIf cfg.enable { + + assertions = attrByPath [ cfg.platformTheme "assertions" ] [] platforms; + + environment.variables = attrByPath [ cfg.platformTheme "environment" "variables" ] {} platforms; + + environment.etc = attrByPath [ cfg.platformTheme "environment" "etc" ] {} platforms; + + environment.systemPackages = attrByPath [ cfg.platformTheme "environment" "systemPackages" ] [] platforms + ++ optionalPackage cfg.font + ++ optionalPackage cfg.style + ++ optionalPackage cfg.iconTheme; + + }; + + meta.maintainers = with maintainers; [ worldofpeace gnidorah ]; +} diff --git a/nixos/modules/config/qt5.nix b/nixos/modules/config/qt5.nix deleted file mode 100644 index fb3e03c4b3fe..000000000000 --- a/nixos/modules/config/qt5.nix +++ /dev/null @@ -1,232 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - - cfg = config.qt5; - - toQtIni = generators.toINI { - mkKeyValue = key: value: - let - value' = - if isBool value then (if value then "true" else "false") - else toString value; - in - "${key}=${value'}"; - }; - - general = - optionalAttrs (cfg.font != null) - { - font = cfg.font.name; - menuFont = cfg.font.name; - toolBarFont = cfg.font.name; - } - // - optionalAttrs (cfg.style != null) - { widgetStyle = cfg.style.name; }; - icons = - optionalAttrs (cfg.iconTheme != null) - { Theme = cfg.iconTheme.name; }; - - fontType = types.submodule { - options = { - package = mkOption { - internal = true; - type = types.nullOr types.package; - default = null; - }; - name = mkOption { - internal = true; - type = types.str; - }; - }; - }; - themeType = types.submodule { - options = { - package = mkOption { - internal = true; - type = types.nullOr types.package; - default = null; - }; - name = mkOption { - internal = true; - type = types.str; - }; - }; - }; - - optionalPackage = opt: - optional (opt != null && opt.package != null) opt.package; - - platforms = { - gtk2 = rec { - description = '' - - gtk2 - Use GTK2 theme with - qtstyleplugins - - - ''; - styles = [ "cleanlooks" "gtk2" "cde" "motif" "plastique" ]; - - assertions = [ - { - assertion = cfg.style != null && any (name: name == cfg.style.name) styles; - message = "`qt5.style.name` is not one of [ ${toString styles} ]."; - } - { - assertion = cfg.font == null && cfg.iconTheme == null; - message = "`qt5.font` and `qt5.iconTheme` are only supported by kde platform."; - } - ]; - environment.variables.QT_QPA_PLATFORMTHEME = "gtk2"; - environment.variables.QT_STYLE_OVERRIDE = cfg.style.name; - environment.systemPackages = [ pkgs.libsForQt5.qtstyleplugins ]; - }; - qgnomeplatform = { - description = '' - - qgnomeplatform - Use GNOME theme with - qgnomeplatform - - - ''; - - assertions = [ - { - assertion = cfg.font == null && cfg.iconTheme == null; - message = "`qt5.font` and `qt5.iconTheme` are only supported by kde platform."; - } - ]; - environment.variables.QT_QPA_PLATFORMTHEME = "qgnomeplatform"; - # TODO: make this optional once https://github.com/NixOS/nixpkgs/issues/54150 is fixed - # qgnomeplatform reads theme and other settings from dconf db - environment.variables.QT_STYLE_OVERRIDE = cfg.style.name; - environment.variables.XDG_DATA_DIRS = [ "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}" ]; - environment.systemPackages = [ pkgs.qgnomeplatform ]; - }; - gtk3 = { - description = '' - - gtk3 - Use GNOME theme with - gtk3 - - - ''; - - assertions = [ - { - assertion = cfg.style != null; - message = "`qt5.platformTheme` gtk3 requires `qt5.style` to be set."; - } - { - assertion = cfg.font == null && cfg.iconTheme == null; - message = "`qt5.font` and `qt5.iconTheme` are only supported by kde platform."; - } - ]; - environment.variables.QT_QPA_PLATFORMTHEME = "gtk3"; - environment.variables.QT_STYLE_OVERRIDE = cfg.style.name; - }; - kde = { - description = '' - - kde - Use Qt theme with - qkdetheme - - - ''; - - environment.variables.XDG_CURRENT_DESKTOP = mkForce "KDE"; - environment.variables.KDE_SESSION_VERSION = "5"; - environment.etc."xdg/kdeglobals".text = - toQtIni { - General = general; - Icons = icons; - }; - }; - }; -in - -{ - - options = { - qt5 = { - - enable = mkEnableOption "Qt5 theming configuration"; - - platformTheme = mkOption { - type = types.enum (attrNames platforms); - example = head (attrNames platforms); - description = '' - Selects the platform theme to use for Qt5 applications. - The options are - - ${concatStrings (mapAttrsToList (name: value: value.description) platforms)} - - ''; - }; - - font = mkOption { - type = types.nullOr fontType; - default = null; - example = literalExample '' - { - name = "Noto Sans,10,-1,5,50,0,0,0,0,0,Regular"; - package = pkgs.noto-fonts; - } - ''; - description = '' - The font to use in Qt applications. - ''; - }; - - iconTheme = mkOption { - type = types.nullOr themeType; - default = null; - example = literalExample '' - { - name = "breeze"; - package = pkgs.breeze-icons; - } - ''; - description = "The icon theme to use."; - }; - - style = mkOption { - type = types.nullOr themeType; - default = null; - example = literalExample '' - { - name = "Breeze"; - package = pkgs.breeze-qt5; - }; - ''; - description = "The Qt style to use."; - }; - - }; - }; - - config = mkIf cfg.enable { - - assertions = attrByPath [ cfg.platformTheme "assertions" ] [] platforms; - - environment.variables = attrByPath [ cfg.platformTheme "environment" "variables" ] {} platforms; - - environment.etc = attrByPath [ cfg.platformTheme "environment" "etc" ] {} platforms; - - environment.systemPackages = attrByPath [ cfg.platformTheme "environment" "systemPackages" ] [] platforms - ++ optionalPackage cfg.font - ++ optionalPackage cfg.style - ++ optionalPackage cfg.iconTheme; - - }; - - meta.maintainers = with maintainers; [ worldofpeace gnidorah ]; -} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 101c235e63f4..089737fcf0ae 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -27,7 +27,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/pantheon.nix b/nixos/modules/services/x11/desktop-managers/pantheon.nix index b46a2d189ef9..5b3fea845964 100644 --- a/nixos/modules/services/x11/desktop-managers/pantheon.nix +++ b/nixos/modules/services/x11/desktop-managers/pantheon.nix @@ -242,9 +242,9 @@ in programs.zsh.vteIntegration = mkDefault true; # Harmonize Qt5 applications under Pantheon - qt5.enable = true; - qt5.platformTheme = "gnome"; - qt5.style = "adwaita"; + qt.enable = true; + qt.platformTheme = "qgnomeplatform"; + qt.style.name = "adwaita"; # Default Fonts fonts.fonts = with pkgs; [ -- cgit 1.4.1