{ lib, config, system, pkgs, ... }: let inherit (lib.snowfall.system) is-linux; cfg = config.marleyos.theme; colorThemes = lib.types.enum [ "rose-pine" ]; colorThemeType = lib.types.submodule { options = { base = lib.mkOption { type = colorThemes; example = "rose-pine"; description = lib.literalMD '' The color theme to use. This should match the base of the enable options provided by the input's module. For instance, the rose-pine home-manager module provides the {option}`rose-pine.enable` base option and the {option}`programs.gtk.rose-pine.enable` option. ''; }; flavor = lib.mkOption { type = with lib.types; nullOr str; default = null; example = "moon"; description = "The theme flavor to use, if applicable."; }; accent = lib.mkOption { type = with lib.types; nullOr str; default = null; example = "rose"; description = "The theme accent to use, if applicable."; }; }; }; mkColorThemeOpt = mode: flavor: (lib.mkOption { type = with lib.types; either str colorThemeType; default = { base = "rose-pine"; inherit flavor; }; description = "The color theme to use in ${mode} mode."; }); # https://github.com/nix-community/home-manager/blob/master/modules/misc/gtk.nix iconThemeType = lib.types.submodule { options = { package = lib.mkOption { type = with lib.types; nullOr package; default = null; 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 available in your profile. ''; }; name = lib.mkOption { type = with lib.types; str; example = "Adwaita"; description = "The name of the icon theme within the package."; }; }; }; 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 = { default = lib.mkOption { type = with lib.types; str; default = "dark"; description = "Whether to prefer the light or dark theme."; }; light = mkColorThemeOpt "light" "dawn"; dark = mkColorThemeOpt "dark" "main"; base = lib.mkOption { type = colorThemes; }; flavor = lib.mkOption { type = with lib.types; nullOr str; }; accent = lib.mkOption { type = with lib.types; nullOr str; }; isRosePine = lib.mkOption { type = with lib.types; bool; }; }; icons = lib.mkOption { type = with lib.types; nullOr iconThemeType; 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 [ # colors { marleyos.theme.colors = rec { inherit (cfg.colors."${cfg.colors.default}") base; inherit (cfg.colors."${cfg.colors.default}") flavor; inherit (cfg.colors."${cfg.colors.default}") accent; # HACK: Need to come up with a better solution isRosePine = base == "rose-pine"; }; } # icons (lib.mkIf ((cfg.icons != null) && (is-linux system)) { gtk = lib.mkDefault { iconTheme = { inherit (cfg.icons) name; package = lib.mkIf (cfg.icons.package != null) cfg.icons.package; }; }; services.dunst = lib.mkDefault { iconTheme = { inherit (cfg.icons) name; package = lib.mkIf (cfg.icons.package != null) cfg.icons.package; }; }; }) # 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]; }; }; } ]; }