diff --git a/modules/home/appearance/base/default.nix b/modules/home/appearance/base/default.nix index 19a8cae..2ff879c 100644 --- a/modules/home/appearance/base/default.nix +++ b/modules/home/appearance/base/default.nix @@ -2,11 +2,9 @@ lib, config, pkgs, - system, ... }: let inherit (lib) mkEnableOption mkIf; - inherit (lib.snowfall.system) is-linux; inherit (lib.marleyos) enabled; cfg = config.marleyos.appearance.base; @@ -46,6 +44,21 @@ in { package = pkgs.kora-icon-theme; name = "kora"; }; + + fonts = { + monospace = { + package = pkgs.maple-mono-NF; + name = "Maple Mono NF"; + ligatures = [ + "cv02" + "ss01" + "ss02" + "ss03" + "ss04" + "ss05" + ]; + }; + }; }; apps = { pinentry = @@ -54,15 +67,5 @@ in { 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 - }; - }; }; } diff --git a/modules/home/options/theme/default.nix b/modules/home/options/theme/default.nix index 263ad5c..4b16e39 100644 --- a/modules/home/options/theme/default.nix +++ b/modules/home/options/theme/default.nix @@ -2,6 +2,7 @@ lib, config, system, + pkgs, ... }: let inherit (lib.snowfall.system) is-linux; @@ -56,7 +57,7 @@ package = lib.mkOption { type = with lib.types; nullOr package; default = null; - example = "pkgs.gnome.adwaita-icon-theme"; + example = pkgs.gnome.adwaita-icon-theme; description = '' Package providing the icon theme. This package will be installed to 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 { options.marleyos.theme = { colors = { @@ -103,6 +130,39 @@ in { default = null; 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 [ @@ -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]; + }; + }; + } ]; } diff --git a/modules/home/programs/wezterm/default.nix b/modules/home/programs/wezterm/default.nix index 4115e0d..abbf743 100644 --- a/modules/home/programs/wezterm/default.nix +++ b/modules/home/programs/wezterm/default.nix @@ -5,7 +5,6 @@ pkgs, ... }: let - inherit (lib) mkEnableOption mkIf; inherit (lib.snowfall.system) is-darwin; cfg = config.marleyos.programs.wezterm; @@ -14,9 +13,9 @@ isGenericLinux = config.targets.genericLinux.enable; isNotNixOS = isGenericLinux || (is-darwin system); 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 = { enable = true; @@ -30,8 +29,7 @@ in { # TODO: create `local config` & return it seperately, so other modules can # insert config in the middle extraConfig = let - # TODO: Set this in marleyos.theme - fonts = config.fonts.fontconfig.defaultFonts.monospace; + inherit (config.marleyos.theme) fonts; in # lua '' @@ -46,18 +44,11 @@ in { config.font = wezterm.font_with_fallback({ { - family = "Maple Mono NF", - -- TODO: Set this in marleyos.theme + family = "${fonts.monospace.name}", harfbuzz_features = { - "cv02", - "ss01", - "ss02", - "ss03", - "ss04", - "ss05", + ${lib.concatStrings fonts.monospace.ligatures} } }, - ${toString (map (font: "{ family = \"${font}\" },") fonts)} { family = "FairiesevkaTerm Nerd Font Mono" }, { family = "FiraCode Nerd Font", @@ -78,10 +69,9 @@ in { "ss07", }, }, - { family = "Apple Color Emoji" }, + { family = "${fonts.emoji.name}" }, }) - -- TODO: on mairley this should be set to 14.0 config.font_size = ${ if (is-darwin system) then "14.0" diff --git a/modules/home/services/dunst/default.nix b/modules/home/services/dunst/default.nix index 29e8c31..96c0c4f 100644 --- a/modules/home/services/dunst/default.nix +++ b/modules/home/services/dunst/default.nix @@ -2,24 +2,17 @@ lib, config, ... -}: -let - inherit (lib) - mkEnableOption - mkIf - mkMerge - ; +}: let inherit (lib.marleyos) disabled; cfg = config.marleyos.services.dunst; inherit (config.marleyos.theme) colors; isRosePine = colors.base == "rose-pine"; -in -{ - options.marleyos.services.dunst.enable = mkEnableOption "dunst"; +in { + options.marleyos.services.dunst.enable = lib.mkEnableOption "dunst"; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.dunst = { enable = true; @@ -28,9 +21,9 @@ in # TODO: Convert dunst.rose-pine to attr set to fix this. rose-pine = disabled; - settings = mkMerge [ + settings = lib.mkMerge [ ### Rose Pine ### - (mkIf isRosePine { + (lib.mkIf isRosePine { global = { width = 400; offset = "20x60"; @@ -77,7 +70,7 @@ in monitor = 0; sort = "yes"; idle_threshold = 120; - font = (builtins.head config.fonts.fontconfig.defaultFonts.monospace) + " 10"; + font = config.marleyos.theme.fonts.monospace.name + " 10"; markup = "full"; show_age_threshold = 60; word_wrap = "yes";