From 79e118e6099358db43a3b8c206a33bb69f1122b2 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 10 Feb 2024 10:34:03 +0800 Subject: [PATCH] {nixos,home-manager,nixvim}/tinted-theming: init --- modules/home-manager/default.nix | 1 + modules/home-manager/tinted-theming.nix | 1 + modules/nixos/default.nix | 1 + modules/nixos/tinted-theming.nix | 141 ++++++++++++++++++++++++ modules/nixvim/default.nix | 1 + modules/nixvim/tinted-theming.nix | 1 + 6 files changed, 146 insertions(+) create mode 120000 modules/home-manager/tinted-theming.nix create mode 100644 modules/nixos/tinted-theming.nix create mode 120000 modules/nixvim/tinted-theming.nix diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 296a3970..72200724 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -12,5 +12,6 @@ ./services/matcha.nix ./services/plover.nix ./services/yt-dlp.nix + ./tinted-theming.nix ]; } diff --git a/modules/home-manager/tinted-theming.nix b/modules/home-manager/tinted-theming.nix new file mode 120000 index 00000000..5c9d3a8b --- /dev/null +++ b/modules/home-manager/tinted-theming.nix @@ -0,0 +1 @@ +../nixos/tinted-theming.nix \ No newline at end of file diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index d8f5cd74..9e557355 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -12,6 +12,7 @@ ./services/wezterm-mux-server.nix ./services/vouch-proxy.nix ./services/yt-dlp.nix + ./tinted-theming.nix ./workflows ]; } diff --git a/modules/nixos/tinted-theming.nix b/modules/nixos/tinted-theming.nix new file mode 100644 index 00000000..677e91da --- /dev/null +++ b/modules/nixos/tinted-theming.nix @@ -0,0 +1,141 @@ +# Essentially a derivative of nix-colors that closely follows Tinted Theming +# "standard" and can hold multiple palettes suitable for generating multiple +# configuration files for organization purposes. +{ config, lib, ... }: + +let + # This follows the schema of a Tinted Theming scheme. Its support for legacy + # Base16 theme is pretty awful for now. Anyways. this would allow a simple + # `lib.importYAML` and wam-bam-thank-you-mam. + schemeType = { name, config, lib, ... }: { + # This would allow extensions to the schema if the scheme author or the + # user wants to add some. + freeformType = with lib.types; attrsOf anything; + + options = { + # The builder will be the one to detect these properly. Though, we could + # also detect this ourselves as well... but with Nixlang? REALLY!?! + system = lib.mkOption { + type = with lib.types; nullOr (enum [ "base16" "base24" ]); + default = null; + example = "base24"; + description = '' + Indicates which system this scheme supports. This is mainly on the + builder to properly detect this. + ''; + }; + + author = lib.mkOption { + type = lib.types.nonEmptyStr; + default = "You"; + example = "Scheme Author"; + description = '' + The scheme author's readable name. + ''; + }; + + name = lib.mkOption { + type = lib.types.nonEmptyStr; + default = name; + example = "Bark on a tree"; + description = '' + The human-readable name of the scheme. + ''; + }; + + description = lib.mkOption { + type = with lib.types; nullOr str; + default = null; + example = "Rusty theme inspired from the forestry (and Nord theme)."; + description = "A short description of the theme."; + }; + + variant = lib.mkOption { + type = with lib.types; nullOr (enum [ "dark" "light" ]); + default = null; + example = "light"; + description = '' + The variant of the theme. This is typically associated with already + existing standards such as the FreeDesktop appearance. + ''; + }; + + palette = lib.mkOption { + type = with lib.types; attrsOf ( + coercedTo str (lib.removePrefix "#") str + ); + default = { }; + example = { + base00 = "2b221f"; + base01 = "412c26"; + base02 = "5c362c"; + base03 = "a45b43"; + base04 = "e1bcb2"; + base05 = "f5ecea"; + base06 = "fefefe"; + base07 = "eb8a65"; + base08 = "d03e68"; + base09 = "df937a"; + base0A = "afa644"; + base0B = "85b26e"; + base0C = "eb914a"; + base0D = "c67f62"; + base0E = "8b7ab9"; + base0F = "7f3F83"; + }; + description = '' + A set of colors. For this module, we place a small additional + restriction in here that all attributes should be a string. It is + common to set colors in HTML hex format. + ''; + }; + }; + }; +in +{ + options.tinted-theming = { + schemes = lib.mkOption { + type = with lib.types; attrsOf (submodule schemeType); + default = { }; + example = { + "bark-on-a-tree" = { + system = "base16"; + author = "Gabriel Arazas"; + description = '' + Rusty and woody theme inspired from forestry (and Nord theme). + ''; + variant = "dark"; + palette = rec { + background = base00; + foreground = base05; + base00 = "2b221f"; + base01 = "412c26"; + base02 = "5c362c"; + base03 = "a45b43"; + base04 = "e1bcb2"; + base05 = "f5ecea"; + base06 = "fefefe"; + base07 = "eb8a65"; + base08 = "d03e68"; + base09 = "df937a"; + base0A = "afa644"; + base0B = "85b26e"; + base0C = "eb914a"; + base0D = "c67f62"; + base0E = "8b7ab9"; + base0F = "7f3F83"; + }; + }; + }; + description = '' + A set of [Tinted Theming](https://github.com/tinted-theming) schemes. + You can set the palette to whatever criteria you deem suitable but + this module closely follows common formats with this theming ecosystem. + + The most common palette scheme is Base16 where the colors are set from + `base00` to `base0F`. Some themes could have 24-colors variant or have + additional meaningful names (e.g., `foreground`, `background`). + ''; + }; + }; +} diff --git a/modules/nixvim/default.nix b/modules/nixvim/default.nix index 0ab3bb2b..3213a085 100644 --- a/modules/nixvim/default.nix +++ b/modules/nixvim/default.nix @@ -4,5 +4,6 @@ ./plugins/firenvim.nix ./plugins/lush-nvim.nix ./plugins/nvim-config-local.nix + ./tinted-theming.nix ]; } diff --git a/modules/nixvim/tinted-theming.nix b/modules/nixvim/tinted-theming.nix new file mode 120000 index 00000000..5c9d3a8b --- /dev/null +++ b/modules/nixvim/tinted-theming.nix @@ -0,0 +1 @@ +../nixos/tinted-theming.nix \ No newline at end of file