theme: setup font options and mgirate theme.nix

This commit is contained in:
Aly Raffauf 2024-08-07 21:44:23 -04:00
parent b254ee282b
commit 5d52af1452
2 changed files with 36 additions and 28 deletions

View file

@ -197,7 +197,27 @@ in {
waybar.enable = lib.mkEnableOption "Waybar wayland panel."; 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."; enable = lib.mkEnableOption "Gtk, Qt, and application colors.";
darkMode = lib.mkOption { 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 { gtk.hideTitleBar = lib.mkOption {
description = "Whether to hide GTK3/4 titlebars (useful for some window managers)."; description = "Whether to hide GTK3/4 titlebars (useful for some window managers).";
default = false; default = false;

View file

@ -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 { in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home = { home = {
packages = [ packages = [
font.package cfg.monospaceFont.package
monospaceFont.package cfg.sansFont.package
cfg.serifFont.package
pkgs.adwaita-qt pkgs.adwaita-qt
pkgs.gnome.adwaita-icon-theme pkgs.gnome.adwaita-icon-theme
pkgs.liberation_ttf pkgs.liberation_ttf
serifFont.package
]; ];
pointerCursor = { pointerCursor = {
@ -86,9 +69,9 @@ in {
enable = true; enable = true;
defaultFonts = { defaultFonts = {
monospace = [monospaceFont.name]; monospace = [cfg.monospaceFont.name];
sansSerif = [font.name]; sansSerif = [cfg.sansFont.name];
serif = [serifFont.name]; serif = [cfg.serifFont.name];
}; };
}; };
@ -104,7 +87,7 @@ in {
package = pkgs.adw-gtk3; package = pkgs.adw-gtk3;
}; };
font = {inherit (font) name package size;}; font = {inherit (cfg.sansFont) name package size;};
iconTheme = { iconTheme = {
name = name =
@ -145,11 +128,11 @@ in {
then "prefer-dark" then "prefer-dark"
else "prefer-light"; else "prefer-light";
document-font-name = "${serifFont.name} ${toString serifFont.size}"; document-font-name = "${cfg.serifFont.name} ${toString cfg.serifFont.size}";
monospace-font-name = "${monospaceFont.name} ${toString monospaceFont.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}";
}; };
}; };
} }