colors: add color options, add catpuccin-mocha.nix

This commit is contained in:
Charlie Root 2024-09-15 20:59:53 +02:00
commit a27db3020e
3 changed files with 61 additions and 8 deletions

View file

@ -1,21 +1,48 @@
{lib, ...}: let
inherit (lib) mkOption;
inherit (lib.types) str;
# NOTE: This module is entirely inspired by raf,
# most of the nix code is also taken from him,
# so please do check out his configuration!
{
config,
lib,
...
}: let
inherit (lib) mkOptionType isString mkOption;
inherit (lib.strings) replaceStrings hasPrefix removePrefix toLower;
inherit (lib.types) enum str coercedTo nullOr attrsOf;
cfg = config.modules.style;
nameToSlug = name: toLower (replaceStrings [" "] ["-"] name);
hexColorType = mkOptionType {
name = "hex-color";
descriptionClass = "noun";
description = "RGB color in hex format";
check = x: isString x && !(hasPrefix "#" x);
};
colorType = attrsOf (coercedTo str (removePrefix "#") hexColorType);
getPaletteFromScheme = slug:
if builtins.pathExists ./palettes/${slug}.nix
then (import ./palettes/${slug}.nix).colorscheme.palette
else throw "The following colorscheme was imported but not found: ${slug}";
in {
options.modules.style = {
colorScheme = {
name = mkOption {
type = str;
type = nullOr (enum ["Catppuccin Mocha" "Catppuccin Latte"]);
default = "Catppuccin Mocha";
};
slug = {
type = str;
default = "catppuccin-mocha";
default = nameToSlug "${toString cfg.colorScheme.name}";
};
variant = {
};
colors =
mkOption {
colors = mkOption {
type = colorType;
default = getPaletteFromScheme cfg.colorScheme.slug;
};
};
};

View file

@ -10,6 +10,7 @@ in {
./qt.nix
./gtk.nix
./fonts.nix
./colors.nix
];
options.modules.style = {

View file

@ -0,0 +1,25 @@
{
colorscheme = {
slug = "catppuccin-mocha";
name = "Catppuccin Mocha";
variant = "dark";
palette = {
base00 = "#1e1e2e"; # Base
base01 = "#181825"; # Mantle
base02 = "#313244"; # Surface0
base03 = "#45475a"; # Surface1
base04 = "#585b70"; # Surface2
base05 = "#cdd6f4"; # text
base06 = "#f5e0dc"; # rosewater
base07 = "#b4befe"; # lavender
base08 = "#f38ba8"; # red
base09 = "#fab387"; # peach
base0A = "#a6e3a1"; # yellow
base0B = "#94e2d5"; # green
base0C = "#94e2d5"; # teal
base0D = "#89b4fa"; # blue
base0E = "#cba6f7"; # mauve
base0F = "#f2cdcd"; # flamingo
};
};
}