Skip to content

Commit

Permalink
home-manager/{gtk,qt}: init
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Oct 18, 2023
1 parent 9b442a5 commit c557ad6
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 75 deletions.
83 changes: 8 additions & 75 deletions home-manager/desktop/theme/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ let
};
in
{
imports = [
./gtk.nix
./qt.nix
];

options.home-manager.desktop.theme = {
enable = lib.mkEnableOption "theme config" // {
default = config.home-manager.desktop.enable;
Expand Down Expand Up @@ -107,74 +112,8 @@ in
};
};

gtk = {
enable = true;
font = {
package = pkgs.noto-fonts;
name = "Noto Sans";
};
iconTheme = {
package = pkgs.nordzy-icon-theme;
name = "Nordzy-dark";
};
theme = {
name = "Nordic-bluish-accent";
package = pkgs.nordic;
};
};

qt = {
enable = true;
platformTheme = "qtct";
style.name = "kvantum";
};

# TODO: remove after this PR is merged
# https://github.com/nix-community/home-manager/pull/4579
home.sessionVariables =
let
inherit (config.home) profileDirectory;
qtVersions = with pkgs; [ qt5 qt6 ];
makeQtPath = prefix: lib.concatStringsSep ":"
(map (qt: "${profileDirectory}/${qt.qtbase.${prefix}}") qtVersions);
in
{
QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}${makeQtPath "qtPluginPrefix"}";
QML2_IMPORT_PATH = "$QML2_IMPORT_PATH\${QML2_IMPORT_PATH:+:}${makeQtPath "qtQmlPrefix"}";
};

xdg.configFile = {
"Kvantum/kvantum.kvconfig".text = lib.generators.toINI { } {
General.theme = "Nordic-bluish-solid";
};
"Kvantum" = {
source = "${pkgs.nordic}/share/Kvantum";
recursive = true;
};
"qt5ct/qt5ct.conf".text = lib.generators.toINI { } {
Appearance = {
style = "kvantum-dark";
icon_theme = config.gtk.iconTheme.name;
standard_dialogs = "gtk3";
};
Interface = {
activate_item_on_single_click = 0;
double_click_interval = 400;
dialog_buttons_have_icons = 1;
wheel_scroll_lines = 3;
};
Fonts = {
# Noto Sans Mono 10
fixed = ''@Variant(\0\0\0@\0\0\0\x1c\0N\0o\0t\0o\0 \0S\0\x61\0n\0s\0 \0M\0o\0n\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)'';
# Noto Sans 10
general = ''@Variant(\0\0\0@\0\0\0\x12\0N\0o\0t\0o\0 \0S\0\x61\0n\0s@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)'';
};
};
"qt6ct/qt6ct.conf".text = config.xdg.configFile."qt5ct/qt5ct.conf".text;
};

# https://github.com/GNOME/gsettings-desktop-schemas/blob/8527b47348ce0573694e0e254785e7c0f2150e16/schemas/org.gnome.desktop.interface.gschema.xml.in#L276-L296
dconf.settings = lib.optionalAttrs (osConfig ? fonts.fontconfig) {
dconf.settings = lib.mkIf (osConfig ? fonts.fontconfig) {
"org/gnome/desktop/interface" = with osConfig.fonts.fontconfig; {
"color-scheme" = "prefer-dark";
"font-antialiasing" =
Expand All @@ -188,15 +127,9 @@ in
};
};

services.xsettingsd = {
services.xsettingsd = lib.mkIf (osConfig ? fonts.fontconfig) {
enable = true;
settings = with config; {
# When running, most GNOME/GTK+ applications prefer those settings
# instead of *.ini files
"Net/IconThemeName" = gtk.iconTheme.name;
"Net/ThemeName" = gtk.theme.name;
"Gtk/CursorThemeName" = xsession.pointerCursor.name;
} // lib.optionalAttrs (osConfig ? fonts.fontconfig) {
settings = {
# Applications like Java/Wine doesn't use Fontconfig settings,
# but uses it from here
"Xft/Antialias" = osConfig.fonts.fontconfig.antialias;
Expand Down
36 changes: 36 additions & 0 deletions home-manager/desktop/theme/gtk.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{ config, pkgs, lib, ... }:

{
options.home-manager.desktop.theme.gtk.enable = lib.mkEnableOption "GTK theme config" // {
default = config.home-manager.desktop.theme.enable;
};

config = lib.mkIf config.home-manager.desktop.theme.gtk.enable {
gtk = {
enable = true;
font = {
package = pkgs.noto-fonts;
name = "Noto Sans";
};
iconTheme = {
package = pkgs.nordzy-icon-theme;
name = "Nordzy-dark";
};
theme = {
name = "Nordic-bluish-accent";
package = pkgs.nordic;
};
};

services.xsettingsd = {
enable = true;
settings = with config; {
# When running, most GNOME/GTK+ applications prefer those settings
# instead of *.ini files
"Net/IconThemeName" = gtk.iconTheme.name;
"Net/ThemeName" = gtk.theme.name;
"Gtk/CursorThemeName" = xsession.pointerCursor.name;
};
};
};
}
59 changes: 59 additions & 0 deletions home-manager/desktop/theme/qt.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{ config, pkgs, lib, ... }:

{
options.home-manager.desktop.theme.qt.enable = lib.mkEnableOption "Qt theme config" // {
default = config.home-manager.desktop.theme.enable;
};

config = lib.mkIf config.home-manager.desktop.theme.qt.enable {
# TODO: remove after this PR is merged
# https://github.com/nix-community/home-manager/pull/4579
home.sessionVariables =
let
inherit (config.home) profileDirectory;
qtVersions = with pkgs; [ qt5 qt6 ];
makeQtPath = prefix: lib.concatStringsSep ":"
(map (qt: "${profileDirectory}/${qt.qtbase.${prefix}}") qtVersions);
in
{
QT_PLUGIN_PATH = "$QT_PLUGIN_PATH\${QT_PLUGIN_PATH:+:}${makeQtPath "qtPluginPrefix"}";
QML2_IMPORT_PATH = "$QML2_IMPORT_PATH\${QML2_IMPORT_PATH:+:}${makeQtPath "qtQmlPrefix"}";
};

qt = {
enable = true;
platformTheme = "qtct";
style.name = "kvantum";
};

xdg.configFile = {
"Kvantum/kvantum.kvconfig".text = lib.generators.toINI { } {
General.theme = "Nordic-bluish-solid";
};
"Kvantum" = {
source = "${pkgs.nordic}/share/Kvantum";
recursive = true;
};
"qt5ct/qt5ct.conf".text = lib.generators.toINI { } {
Appearance = {
style = "kvantum-dark";
icon_theme = config.gtk.iconTheme.name;
standard_dialogs = "gtk3";
};
Interface = {
activate_item_on_single_click = 0;
double_click_interval = 400;
dialog_buttons_have_icons = 1;
wheel_scroll_lines = 3;
};
Fonts = {
# Noto Sans Mono 10
fixed = ''@Variant(\0\0\0@\0\0\0\x1c\0N\0o\0t\0o\0 \0S\0\x61\0n\0s\0 \0M\0o\0n\0o@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)'';
# Noto Sans 10
general = ''@Variant(\0\0\0@\0\0\0\x12\0N\0o\0t\0o\0 \0S\0\x61\0n\0s@$\0\0\0\0\0\0\xff\xff\xff\xff\x5\x1\0\x32\x10)'';
};
};
"qt6ct/qt6ct.conf".text = config.xdg.configFile."qt5ct/qt5ct.conf".text;
};
};
}

0 comments on commit c557ad6

Please sign in to comment.