feat(home): Add fonts to theme module

This commit is contained in:
punkfairie 2025-01-12 12:12:40 -08:00
parent fc937102da
commit 00b31c9a52
No known key found for this signature in database
GPG key ID: B3C5488E9A1A7CA6
4 changed files with 109 additions and 43 deletions

View file

@ -2,11 +2,9 @@
lib, lib,
config, config,
pkgs, pkgs,
system,
... ...
}: let }: let
inherit (lib) mkEnableOption mkIf; inherit (lib) mkEnableOption mkIf;
inherit (lib.snowfall.system) is-linux;
inherit (lib.marleyos) enabled; inherit (lib.marleyos) enabled;
cfg = config.marleyos.appearance.base; cfg = config.marleyos.appearance.base;
@ -46,6 +44,21 @@ in {
package = pkgs.kora-icon-theme; package = pkgs.kora-icon-theme;
name = "kora"; name = "kora";
}; };
fonts = {
monospace = {
package = pkgs.maple-mono-NF;
name = "Maple Mono NF";
ligatures = [
"cv02"
"ss01"
"ss02"
"ss03"
"ss04"
"ss05"
];
};
};
}; };
apps = { apps = {
pinentry = pinentry =
@ -54,15 +67,5 @@ in {
else pkgs.pinentry-curses; else pkgs.pinentry-curses;
}; };
}; };
fonts.fontconfig = mkIf (is-linux system) {
enable = true;
defaultFonts = {
monospace = ["Maple Mono NF"];
sansSerif = ["DeepMind Sans"]; # dm-sans
serif = ["EB Garamond"];
emoji = ["Apple Color Emoji"]; # whatsapp-emoji-font
};
};
}; };
} }

View file

@ -2,6 +2,7 @@
lib, lib,
config, config,
system, system,
pkgs,
... ...
}: let }: let
inherit (lib.snowfall.system) is-linux; inherit (lib.snowfall.system) is-linux;
@ -56,7 +57,7 @@
package = lib.mkOption { package = lib.mkOption {
type = with lib.types; nullOr package; type = with lib.types; nullOr package;
default = null; default = null;
example = "pkgs.gnome.adwaita-icon-theme"; example = pkgs.gnome.adwaita-icon-theme;
description = '' description = ''
Package providing the icon theme. This package will be installed to Package providing the icon theme. This package will be installed to
your profile. If `null` then the theme is assumed to already be your profile. If `null` then the theme is assumed to already be
@ -71,6 +72,32 @@
}; };
}; };
}; };
mkFontType = type: default: (lib.mkOption {
type = lib.types.submodule {
options = {
package = lib.mkOption {
type = with lib.types; package;
default = default.package;
description = "The package providing the ${type} font.";
};
name = lib.mkOption {
type = with lib.types; str;
default = default.name;
description = "The name of the ${type} font.";
};
ligatures = lib.mkOption {
type = with lib.types; listOf str;
default = default.ligatures;
description = "The ligature features to enable for programs that support it.";
};
};
};
inherit default;
description = "The ${type} font to use.";
});
in { in {
options.marleyos.theme = { options.marleyos.theme = {
colors = { colors = {
@ -103,6 +130,39 @@ in {
default = null; default = null;
description = "The icon theme to use."; description = "The icon theme to use.";
}; };
fonts = lib.mkOption {
type = with lib.types;
submodule {
options = {
monospace = mkFontType "monospace" {
package = pkgs.maple-mono-NF;
name = "Maple Mono NF";
ligatures = [];
};
sansSerif = mkFontType "sans-serif" {
package = pkgs.dm-sans;
name = "DeepMind Sans";
ligatures = [];
};
serif = mkFontType "serif" {
package = pkgs.eb-garamond;
name = "EB Garamond";
ligatures = [];
};
emoji = mkFontType "emoji" {
package = pkgs.whatsapp-emoji-font;
name = "Apple Color Emoji";
ligatures = [];
};
};
};
default = {};
description = "Default font configuration.";
};
}; };
config = lib.mkMerge [ config = lib.mkMerge [
@ -134,5 +194,25 @@ in {
}; };
}; };
}) })
# fonts
{
home.packages = [
cfg.fonts.monospace.package
cfg.fonts.sansSerif.package
cfg.fonts.serif.package
cfg.fonts.emoji.package
];
fonts.fontconfig = lib.mkIf (is-linux system) {
enable = true;
defaultFonts = {
monospace = [cfg.fonts.monospace.name];
sansSerif = [cfg.fonts.sansSerif.name];
serif = [cfg.fonts.serif.name];
emoji = [cfg.fonts.emoji.name];
};
};
}
]; ];
} }

View file

@ -5,7 +5,6 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkEnableOption mkIf;
inherit (lib.snowfall.system) is-darwin; inherit (lib.snowfall.system) is-darwin;
cfg = config.marleyos.programs.wezterm; cfg = config.marleyos.programs.wezterm;
@ -14,9 +13,9 @@
isGenericLinux = config.targets.genericLinux.enable; isGenericLinux = config.targets.genericLinux.enable;
isNotNixOS = isGenericLinux || (is-darwin system); isNotNixOS = isGenericLinux || (is-darwin system);
in { in {
options.marleyos.programs.wezterm.enable = mkEnableOption "wezterm"; options.marleyos.programs.wezterm.enable = lib.mkEnableOption "wezterm";
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.wezterm = { programs.wezterm = {
enable = true; enable = true;
@ -30,8 +29,7 @@ in {
# TODO: create `local config` & return it seperately, so other modules can # TODO: create `local config` & return it seperately, so other modules can
# insert config in the middle # insert config in the middle
extraConfig = let extraConfig = let
# TODO: Set this in marleyos.theme inherit (config.marleyos.theme) fonts;
fonts = config.fonts.fontconfig.defaultFonts.monospace;
in in
# lua # lua
'' ''
@ -46,18 +44,11 @@ in {
config.font = wezterm.font_with_fallback({ config.font = wezterm.font_with_fallback({
{ {
family = "Maple Mono NF", family = "${fonts.monospace.name}",
-- TODO: Set this in marleyos.theme
harfbuzz_features = { harfbuzz_features = {
"cv02", ${lib.concatStrings fonts.monospace.ligatures}
"ss01",
"ss02",
"ss03",
"ss04",
"ss05",
} }
}, },
${toString (map (font: "{ family = \"${font}\" },") fonts)}
{ family = "FairiesevkaTerm Nerd Font Mono" }, { family = "FairiesevkaTerm Nerd Font Mono" },
{ {
family = "FiraCode Nerd Font", family = "FiraCode Nerd Font",
@ -78,10 +69,9 @@ in {
"ss07", "ss07",
}, },
}, },
{ family = "Apple Color Emoji" }, { family = "${fonts.emoji.name}" },
}) })
-- TODO: on mairley this should be set to 14.0
config.font_size = ${ config.font_size = ${
if (is-darwin system) if (is-darwin system)
then "14.0" then "14.0"

View file

@ -2,24 +2,17 @@
lib, lib,
config, config,
... ...
}: }: let
let
inherit (lib)
mkEnableOption
mkIf
mkMerge
;
inherit (lib.marleyos) disabled; inherit (lib.marleyos) disabled;
cfg = config.marleyos.services.dunst; cfg = config.marleyos.services.dunst;
inherit (config.marleyos.theme) colors; inherit (config.marleyos.theme) colors;
isRosePine = colors.base == "rose-pine"; isRosePine = colors.base == "rose-pine";
in in {
{ options.marleyos.services.dunst.enable = lib.mkEnableOption "dunst";
options.marleyos.services.dunst.enable = mkEnableOption "dunst";
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.dunst = { services.dunst = {
enable = true; enable = true;
@ -28,9 +21,9 @@ in
# TODO: Convert dunst.rose-pine to attr set to fix this. # TODO: Convert dunst.rose-pine to attr set to fix this.
rose-pine = disabled; rose-pine = disabled;
settings = mkMerge [ settings = lib.mkMerge [
### Rose Pine ### ### Rose Pine ###
(mkIf isRosePine { (lib.mkIf isRosePine {
global = { global = {
width = 400; width = 400;
offset = "20x60"; offset = "20x60";
@ -77,7 +70,7 @@ in
monitor = 0; monitor = 0;
sort = "yes"; sort = "yes";
idle_threshold = 120; idle_threshold = 120;
font = (builtins.head config.fonts.fontconfig.defaultFonts.monospace) + " 10"; font = config.marleyos.theme.fonts.monospace.name + " 10";
markup = "full"; markup = "full";
show_age_threshold = 60; show_age_threshold = 60;
word_wrap = "yes"; word_wrap = "yes";