From 5d52af145225031c8189ee1f92e5e357d994787a Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Wed, 7 Aug 2024 21:44:23 -0400 Subject: [PATCH] theme: setup font options and mgirate theme.nix --- homeManagerModules/options.nix | 27 ++++++++++++++++++++++++- homeManagerModules/theme.nix | 37 +++++++++------------------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/homeManagerModules/options.nix b/homeManagerModules/options.nix index ca1b1f9a..7783a1d1 100644 --- a/homeManagerModules/options.nix +++ b/homeManagerModules/options.nix @@ -197,7 +197,27 @@ in { waybar.enable = lib.mkEnableOption "Waybar wayland panel."; }; - theme = { + theme = let + mkFontOption = typ: nam: pkg: siz: { + name = lib.mkOption { + description = "Default ${typ} font name."; + default = nam; + type = lib.types.str; + }; + + package = lib.mkOption { + description = "Default ${typ} font package."; + default = pkg; + type = lib.types.package; + }; + + size = lib.mkOption { + description = "Default ${typ} font size."; + default = siz; + type = lib.types.int; + }; + }; + in { enable = lib.mkEnableOption "Gtk, Qt, and application colors."; darkMode = lib.mkOption { @@ -244,6 +264,11 @@ in { }; }; + sansFont = mkFontOption "sans serif" "UbuntuSans Nerd Font" (pkgs.nerdfonts.override {fonts = ["UbuntuSans"];}) 11; + serifFont = mkFontOption "serif" "Vegur" pkgs.vegur 11; + monospaceFont = mkFontOption "monospace" "UbuntuSansMono Nerd Font" (pkgs.nerdfonts.override {fonts = ["UbuntuSans"];}) 11; + + gtk.hideTitleBar = lib.mkOption { description = "Whether to hide GTK3/4 titlebars (useful for some window managers)."; default = false; diff --git a/homeManagerModules/theme.nix b/homeManagerModules/theme.nix index e3717c13..23421685 100644 --- a/homeManagerModules/theme.nix +++ b/homeManagerModules/theme.nix @@ -40,33 +40,16 @@ } ''; }; - - font = { - name = "UbuntuSans Nerd Font"; - package = pkgs.nerdfonts.override {fonts = ["UbuntuSans"];}; - size = 11; - }; - - monospaceFont = { - inherit (font) package size; - name = "UbuntuSansMono Nerd Font"; - }; - - serifFont = { - inherit (font) size; - name = "Vegur"; - package = pkgs.vegur; - }; in { config = lib.mkIf cfg.enable { home = { packages = [ - font.package - monospaceFont.package + cfg.monospaceFont.package + cfg.sansFont.package + cfg.serifFont.package pkgs.adwaita-qt pkgs.gnome.adwaita-icon-theme pkgs.liberation_ttf - serifFont.package ]; pointerCursor = { @@ -86,9 +69,9 @@ in { enable = true; defaultFonts = { - monospace = [monospaceFont.name]; - sansSerif = [font.name]; - serif = [serifFont.name]; + monospace = [cfg.monospaceFont.name]; + sansSerif = [cfg.sansFont.name]; + serif = [cfg.serifFont.name]; }; }; @@ -104,7 +87,7 @@ in { package = pkgs.adw-gtk3; }; - font = {inherit (font) name package size;}; + font = {inherit (cfg.sansFont) name package size;}; iconTheme = { name = @@ -145,11 +128,11 @@ in { then "prefer-dark" else "prefer-light"; - document-font-name = "${serifFont.name} ${toString serifFont.size}"; - monospace-font-name = "${monospaceFont.name} ${toString monospaceFont.size}"; + document-font-name = "${cfg.serifFont.name} ${toString cfg.serifFont.size}"; + monospace-font-name = "${cfg.monospaceFont.name} ${toString cfg.monospaceFont.size}"; }; - "org/gnome/desktop/wm/preferences".titlebar-font = "${font.name} ${toString font.size}"; + "org/gnome/desktop/wm/preferences".titlebar-font = "${cfg.sansFont.name} ${toString cfg.sansFont.size}"; }; }; }