From 4f3cedefa6409e04115a180c400a5b42227134dd Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Wed, 3 Jul 2024 20:20:16 +0300 Subject: [PATCH] Add theme font, icon options Signed-off-by: Nikolaos Karaolidis --- hosts/eirene/base/default.nix | 6 +- .../options/home-manager/theme/default.nix | 116 ++++++++++++++++-- users/configs/ags/theme.sass | 2 + users/configs/gtk/default.nix | 13 +- users/configs/hyprland/theme.conf | 2 + users/configs/kitty/default.nix | 7 ++ users/configs/matugen/default.nix | 8 ++ users/configs/rofi/default.nix | 9 +- users/configs/vscode/default.nix | 10 +- users/configs/{x => x11}/default.nix | 1 + users/nick/default.nix | 2 +- 11 files changed, 156 insertions(+), 20 deletions(-) rename users/configs/{x => x11}/default.nix (85%) diff --git a/hosts/eirene/base/default.nix b/hosts/eirene/base/default.nix index 3f8e537..d29c206 100644 --- a/hosts/eirene/base/default.nix +++ b/hosts/eirene/base/default.nix @@ -68,7 +68,11 @@ gestures.workspace_swipe_distance = 600; }; - programs.zsh.loginExtra = lib.mkBefore (builtins.readFile ./card.sh); + programs = { + zsh.loginExtra = lib.mkBefore (builtins.readFile ./card.sh); + # VSCode does not play well with fractional scaling + vscode.userSettings."window.zoomLevel" = (1.25 - 1) / 0.2; + }; theme = { cursor.size = 24; diff --git a/users/common/options/home-manager/theme/default.nix b/users/common/options/home-manager/theme/default.nix index 1cb1729..bcb06db 100644 --- a/users/common/options/home-manager/theme/default.nix +++ b/users/common/options/home-manager/theme/default.nix @@ -236,6 +236,62 @@ in }; font = { + sansSerif = { + names = mkOption { + type = listOf str; + default = [ "Roboto" ]; + description = "The sans serif font families."; + }; + + packages = mkOption { + type = listOf package; + default = with pkgs; [ roboto ]; + description = "The sans serif font packages."; + }; + }; + + serif = { + names = mkOption { + type = listOf str; + default = [ "Roboto Serif" ]; + description = "The serif font families."; + }; + + packages = mkOption { + type = listOf package; + default = with pkgs; [ roboto-serif ]; + description = "The serif font packages."; + }; + }; + + monospace = { + names = mkOption { + type = listOf str; + default = [ "JetBrainsMono Nerd Font" ]; + description = "The monospace font families."; + }; + + packages = mkOption { + type = listOf package; + default = with pkgs; [ (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) ]; + description = "The monospace font packages."; + }; + }; + + emoji = { + names = mkOption { + type = listOf str; + default = [ "Noto Emoji" "Font Awesome" ]; + description = "The emoji font families."; + }; + + packages = mkOption { + type = listOf package; + default = with pkgs; [ noto-fonts-color-emoji font-awesome ]; + description = "The emoji font packages."; + }; + }; + size = mkOption { type = ints.positive; default = 12; @@ -243,17 +299,34 @@ in }; }; - cursor = { - package = mkOption { - type = package; - default = pkgs.gnome.adwaita-icon-theme; - description = "The package providing the cursor theme."; + icon = { + names = mkOption { + type = listOf str; + default = [ "Adwaita" ]; + description = "The icon theme names."; }; - name = mkOption { - type = str; - default = "Adwaita"; - description = "The cursor name within the package."; + packages = mkOption { + type = listOf package; + default = with pkgs; [ + gnome.adwaita-icon-theme + nixos-icons + ]; + description = "The icon theme packages."; + }; + }; + + cursor = { + names = mkOption { + type = listOf str; + default = [ "Adwaita" ]; + description = "The cursor names."; + }; + + packages = mkOption { + type = listOf package; + default = with pkgs; [ gnome.adwaita-icon-theme ]; + description = "The cursor theme packages."; }; size = mkOption { @@ -266,12 +339,29 @@ in config = lib.mkIf cfg.enable { home = { - packages = [ cfg.pkg ]; + packages = + [ cfg.pkg ] ++ + cfg.font.sansSerif.packages ++ + cfg.font.serif.packages ++ + cfg.font.monospace.packages ++ + cfg.font.emoji.packages ++ + cfg.icon.packages ++ + cfg.cursor.packages; pointerCursor = { - inherit (cfg.cursor) package name size; - gtk.enable = true; - x11.enable = true; + name = builtins.head cfg.cursor.names; + package = builtins.head cfg.cursor.packages; + inherit (cfg.cursor) size; + }; + }; + + fonts.fontconfig = { + enable = true; + defaultFonts = { + sansSerif = cfg.font.sansSerif.names; + serif = cfg.font.serif.names; + monospace = cfg.font.monospace.names; + emoji = cfg.font.emoji.names; }; }; }; diff --git a/users/configs/ags/theme.sass b/users/configs/ags/theme.sass index b29c653..a85ef25 100644 --- a/users/configs/ags/theme.sass +++ b/users/configs/ags/theme.sass @@ -60,4 +60,6 @@ .label color: {{colors.on_surface.default.hex}} font-size: {{custom.font_size}}pt + font-family: {{custom.font_sans_serif_all}} + font-weight: 500 margin: 0 .5 * {{custom.padding}}pt diff --git a/users/configs/gtk/default.nix b/users/configs/gtk/default.nix index 69565c6..89f25c3 100644 --- a/users/configs/gtk/default.nix +++ b/users/configs/gtk/default.nix @@ -13,12 +13,23 @@ in name = "adw-gtk3-dark"; }; + font = { + name = builtins.head hmConfig.theme.font.sansSerif.names; + package = builtins.head hmConfig.theme.font.sansSerif.packages; + inherit (hmConfig.theme.font) size; + }; + + iconTheme = { + name = builtins.head hmConfig.theme.icon.names; + package = builtins.head hmConfig.theme.icon.packages; + }; + gtk2.configLocation = "${hmConfig.xdg.configHome}/gtk-2.0/gtkrc"; gtk3.extraCss = "@import './theme.css';"; gtk4.extraCss = "@import './theme.css';"; }; - home.packages = with pkgs; [ nixos-icons ]; + home.pointerCursor.gtk.enable = true; programs.matugen.settings.templates = { gtk3 = { diff --git a/users/configs/hyprland/theme.conf b/users/configs/hyprland/theme.conf index 73a6b55..c979f55 100644 --- a/users/configs/hyprland/theme.conf +++ b/users/configs/hyprland/theme.conf @@ -17,4 +17,6 @@ decoration { misc { col.splash = rgb({{colors.on_surface.default.hex_stripped}}) background_color = rgb({{colors.surface.default.hex_stripped}}) + font_family = {{custom.font_sans_serif}} + splash_font_family = {{custom.font_monospace}} } diff --git a/users/configs/kitty/default.nix b/users/configs/kitty/default.nix index 8c7c664..46e8979 100644 --- a/users/configs/kitty/default.nix +++ b/users/configs/kitty/default.nix @@ -8,6 +8,13 @@ in programs = { kitty = { enable = true; + + font = { + name = builtins.head hmConfig.theme.font.monospace.names; + package = builtins.head hmConfig.theme.font.monospace.packages; + inherit (hmConfig.theme.font) size; + }; + extraConfig = '' confirm_os_window_close 0 include theme.conf diff --git a/users/configs/matugen/default.nix b/users/configs/matugen/default.nix index 874f576..bac3a7f 100644 --- a/users/configs/matugen/default.nix +++ b/users/configs/matugen/default.nix @@ -57,6 +57,14 @@ in opacity_shadow = builtins.toString (hmConfig.theme.opacity * .75); opacity_shadow_hex = builtins.toString (percentageToHex (hmConfig.theme.opacity * .75)); font_size = builtins.toString hmConfig.theme.font.size; + font_sans_serif = builtins.head hmConfig.theme.font.sansSerif.names; + font_sans_serif_all = builtins.concatStringsSep ", " hmConfig.theme.font.sansSerif.names; + font_serif = builtins.head hmConfig.theme.font.serif.names; + font_serif_all = builtins.concatStringsSep ", " hmConfig.theme.font.serif.names; + font_monospace = builtins.head hmConfig.theme.font.monospace.names; + font_monospace_all = builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names; + font_emoji = builtins.head hmConfig.theme.font.emoji.names; + font_emoji_all = builtins.concatStringsSep ", " hmConfig.theme.font.emoji.names; }; }; diff --git a/users/configs/rofi/default.nix b/users/configs/rofi/default.nix index 3f57dfd..27b022f 100644 --- a/users/configs/rofi/default.nix +++ b/users/configs/rofi/default.nix @@ -5,11 +5,14 @@ let in { home-manager.users.${user.name} = { - home = { - packages = with pkgs; [ rofi-wayland ]; - persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/rofi" ]; + programs.rofi = { + enable = true; + package = pkgs.rofi-wayland; + font = builtins.head hmConfig.theme.font.monospace.names; }; + home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/rofi" ]; + wayland.windowManager.hyprland.settings.bind = [ "$mod, r, exec, ${lib.meta.getExe pkgs.rofi-wayland} -cache-dir ${hmConfig.xdg.cacheHome}/rofi -show drun" ]; diff --git a/users/configs/vscode/default.nix b/users/configs/vscode/default.nix index c1004b8..2581293 100644 --- a/users/configs/vscode/default.nix +++ b/users/configs/vscode/default.nix @@ -1,5 +1,8 @@ -{ user ? throw "user argument is required" }: { inputs, lib, pkgs, ... }: +{ user ? throw "user argument is required" }: { config, inputs, lib, pkgs, ... }: +let + hmConfig = config.home-manager.users.${user.name}; +in { home-manager.users.${user.name} = { programs.vscode = { @@ -10,6 +13,9 @@ "editor.accessibilitySupport" = "off"; "editor.cursorBlinking" = "phase"; "editor.cursorSmoothCaretAnimation" = "on"; + "editor.fontFamily" = builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names; + "editor.fontLigatures" = true; + "editor.fontSize" = hmConfig.theme.font.size; "editor.formatOnPaste" = true; "editor.formatOnSave" = true; "editor.formatOnType" = true; @@ -50,6 +56,8 @@ "terminal.external.linuxExec" = "kitty"; "terminal.integrated.confirmOnExit" = "hasChildProcesses"; "terminal.integrated.copyOnSelection" = true; + "terminal.integrated.fontFamily" = builtins.concatStringsSep ", " hmConfig.theme.font.monospace.names; + "terminal.integrated.fontSize" = hmConfig.theme.font.size; "window.autoDetectHighContrast" = false; "window.menuBarVisibility" = "toggle"; "workbench.editor.historyBasedLanguageDetection" = true; diff --git a/users/configs/x/default.nix b/users/configs/x11/default.nix similarity index 85% rename from users/configs/x/default.nix rename to users/configs/x11/default.nix index 6aa8d8b..b69d795 100644 --- a/users/configs/x/default.nix +++ b/users/configs/x11/default.nix @@ -5,6 +5,7 @@ let in { home-manager.users.${user.name} = { + home.pointerCursor.x11.enable = true; xresources.path = "${hmConfig.xdg.configHome}/X11/xresources"; }; } diff --git a/users/nick/default.nix b/users/nick/default.nix index ca0bea0..d82357d 100644 --- a/users/nick/default.nix +++ b/users/nick/default.nix @@ -22,7 +22,7 @@ in (import ../configs/swww { inherit user; }) (import ../configs/kitty { inherit user; }) (import ../configs/gtk { inherit user; }) - (import ../configs/x { inherit user; }) + (import ../configs/x11 { inherit user; }) (import ../configs/vscode { inherit user; }) (import ../configs/qalculate { inherit user; }) ];