qol(base16): hex to rgb possible

This commit is contained in:
2026-01-11 01:54:56 +01:00
parent 9151cb04eb
commit 57dfdc2cab
2 changed files with 42 additions and 116 deletions

View File

@@ -12,107 +12,34 @@
# author: "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)"
# variant: "dark"
let
cfg_hex = {
"01" = "#1d2021"; # base00
"02" = "#3c3836"; # base01
"03" = "#504945"; # base02
"04" = "#665c54"; # base03
"05" = "#bdae93"; # base04
"06" = "#d5c4a1"; # base05
"07" = "#ebdbb2"; # base06
"08" = "#fbf1c7"; # base07
"09" = "#fb4934"; # base08 (red)
"10" = "#fe8019"; # base09 (orange)
"11" = "#fabd2f"; # base0A (yellow)
"12" = "#b8bb26"; # base0B (green)
"13" = "#8ec07c"; # base0C (aqua/cyan)
"14" = "#83a598"; # base0D (blue)
"15" = "#d3869b"; # base0E (purple)
"16" = "#d65d0e"; # base0F (brown)
};
cfg_rgb = {
"01" = {
r = 29;
g = 32;
b = 33;
}; # base00
"02" = {
r = 60;
g = 56;
b = 54;
}; # base01
"03" = {
r = 80;
g = 73;
b = 69;
}; # base02
"04" = {
r = 102;
g = 92;
b = 84;
}; # base03
"05" = {
r = 189;
g = 174;
b = 147;
}; # base04
"06" = {
r = 213;
g = 196;
b = 161;
}; # base05
"07" = {
r = 235;
g = 219;
b = 178;
}; # base06
"08" = {
r = 251;
g = 241;
b = 199;
}; # base07
"09" = {
r = 251;
g = 73;
b = 52;
}; # base08 (red)
"10" = {
r = 254;
g = 128;
b = 25;
}; # base09 (orange)
"11" = {
r = 250;
g = 189;
b = 47;
}; # base0A (yellow)
"12" = {
r = 184;
g = 187;
b = 38;
}; # base0B (green)
"13" = {
r = 142;
g = 192;
b = 124;
}; # base0C (aqua/cyan)
"14" = {
r = 131;
g = 165;
b = 152;
}; # base0D (blue)
"15" = {
r = 211;
g = 134;
b = 155;
}; # base0E (purple)
"16" = {
r = 214;
g = 93;
b = 14;
}; # base0F (brown)
};
hexToInt = hex: fromTOML "value = 0x${hex}";
hexToRgb =
hex:
let
red = hexToInt (builtins.substring 1 2 hex);
green = hexToInt (builtins.substring 3 2 hex);
blue = hexToInt (builtins.substring 5 2 hex);
in
{
r = red.value;
g = green.value;
b = blue.value;
};
theme =
let
importYaml =
file:
builtins.fromJSON (
builtins.readFile (
pkgs.runCommandNoCC "converted-yaml.json" { } ''
${pkgs.yj}/bin/yj < ${file} > $out
''
)
);
# EDIT THEME HERE
themeFile = "${pkgs.base16-schemes}/share/themes/gruvbox-dark-hard.yaml";
in
importYaml themeFile;
in
{
options.modules.base16 = {
@@ -121,17 +48,15 @@ in
description = ''
Hexadecimal color configuration for Gruvbox dark, hard Base16 theme.
'';
default = cfg_hex;
};
rgb = lib.mkOption {
type = lib.types.attrs;
description = ''
RGB color configuration for Gruvbox dark, hard Base16 theme.
Hexadecimal color configuration for Gruvbox dark, hard Base16 theme.
'';
default = cfg_rgb;
};
};
config.modules.base16.hex = cfg_hex;
config.modules.base16.rgb = cfg_rgb;
config.modules.base16.hex = theme.palette;
config.modules.base16.rgb = builtins.mapAttrs (_name: hex: hexToRgb hex) theme.palette;
}