Files
dotfiles/modules/base16-theme/home.nix

63 lines
1.4 KiB
Nix

{
config,
lib,
inputs,
pkgs,
home,
system,
...
}:
# system: "base16"
# name: "Gruvbox dark, hard"
# author: "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)"
# variant: "dark"
let
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 = {
hex = lib.mkOption {
type = lib.types.attrs;
description = ''
Hexadecimal color configuration for Gruvbox dark, hard Base16 theme.
'';
};
rgb = lib.mkOption {
type = lib.types.attrs;
description = ''
Hexadecimal color configuration for Gruvbox dark, hard Base16 theme.
'';
};
};
config.modules.base16.hex = theme.palette;
config.modules.base16.rgb = builtins.mapAttrs (_name: hex: hexToRgb hex) theme.palette;
}