Modules/Color: Don't specify light/dark schemes, choose a single scheme where everything is based on
This commit is contained in:
@ -10,11 +10,7 @@ in {
|
||||
options.modules.color = import ./options.nix {inherit lib mylib;};
|
||||
|
||||
config = let
|
||||
lightDefs = import ./schemes/${color.lightScheme}.nix;
|
||||
darkDefs = import ./schemes/${color.darkScheme}.nix;
|
||||
|
||||
# Assignments will be generated from those keys
|
||||
colorKeys = builtins.attrNames lightDefs;
|
||||
colorDefs = import ./schemes/${color.scheme}.nix;
|
||||
|
||||
mkColorAssignment = defs: key: {${key} = defs.${key};};
|
||||
mkStringColorAssignment = defs: key: {${key} = "#${defs.${key}}";};
|
||||
@ -23,17 +19,20 @@ in {
|
||||
in {
|
||||
# Helper script that processes a visual mode selection and replaces
|
||||
# referenced colors in-place with their counterparts in this module.
|
||||
# Usage: '<,'>!applyColors<cr>
|
||||
# Usage: ":'<,'>!applyColors<cr>"
|
||||
home.packages = let
|
||||
applyColors = let
|
||||
mkPythonColorDef = name: value: " '${name}': '${value}',";
|
||||
in
|
||||
mkPythonColorDef = name: value: " '${name}': '${value}',";
|
||||
|
||||
applyColors =
|
||||
pkgs.writers.writePython3Bin
|
||||
"applyColors"
|
||||
{
|
||||
doCheck = false;
|
||||
}
|
||||
(
|
||||
builtins.concatStringsSep "\n" [
|
||||
"colors: dict[str, str] = {"
|
||||
(config.modules.color.hex.dark
|
||||
(config.modules.color.hex
|
||||
|> builtins.mapAttrs mkPythonColorDef
|
||||
|> builtins.attrValues
|
||||
|> builtins.concatStringsSep "\n")
|
||||
@ -44,56 +43,34 @@ in {
|
||||
in [applyColors];
|
||||
|
||||
# This module sets its own options to the values specified in a colorscheme file.
|
||||
# TODO: This is fucking stupid. Add an option to set a colorscheme,
|
||||
# then provide a single hex/rgb/rgbString set, not this light/dark shit.
|
||||
modules.color = {
|
||||
hex = {
|
||||
light =
|
||||
colorKeys
|
||||
|> builtins.map (mkColorAssignment lightDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
# RRGGBB (0-F)
|
||||
hex =
|
||||
colorDefs
|
||||
|> builtins.attrNames
|
||||
|> builtins.map (mkColorAssignment colorDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
|
||||
dark =
|
||||
colorKeys
|
||||
|> builtins.map (mkColorAssignment darkDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
};
|
||||
# #RRGGBB (0-F)
|
||||
hexS =
|
||||
colorDefs
|
||||
|> builtins.attrNames
|
||||
|> builtins.map (mkStringColorAssignment colorDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
|
||||
hexString = {
|
||||
light =
|
||||
colorKeys
|
||||
|> builtins.map (mkStringColorAssignment lightDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
# [RR GG BB] (0-255)
|
||||
rgb =
|
||||
colorDefs
|
||||
|> builtins.attrNames
|
||||
|> builtins.map (mkRgbColorAssignment colorDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
|
||||
dark =
|
||||
colorKeys
|
||||
|> builtins.map (mkStringColorAssignment darkDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
};
|
||||
|
||||
rgb = {
|
||||
light =
|
||||
colorKeys
|
||||
|> builtins.map (mkRgbColorAssignment lightDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
|
||||
dark =
|
||||
colorKeys
|
||||
|> builtins.map (mkRgbColorAssignment darkDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
};
|
||||
|
||||
rgbString = {
|
||||
light =
|
||||
colorKeys
|
||||
|> builtins.map (mkRgbStringColorAssignment lightDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
|
||||
dark =
|
||||
colorKeys
|
||||
|> builtins.map (mkRgbStringColorAssignment darkDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
};
|
||||
# RR,GG,BB (0-255)
|
||||
rgbS =
|
||||
colorDefs
|
||||
|> builtins.attrNames
|
||||
|> builtins.map (mkRgbStringColorAssignment colorDefs)
|
||||
|> lib.mergeAttrsList;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -2,25 +2,19 @@
|
||||
lib,
|
||||
mylib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with mylib.modules; {
|
||||
lightScheme = mkOption {
|
||||
type = types.str;
|
||||
description = "The color scheme to use for light colors";
|
||||
example = "catppuccin-latte";
|
||||
default = "catppuccin-latte";
|
||||
};
|
||||
|
||||
darkScheme = mkOption {
|
||||
type = types.str;
|
||||
description = "The color scheme to use for dark colors";
|
||||
}: {
|
||||
scheme = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"catppuccin-latte"
|
||||
"catppuccin-mocha"
|
||||
];
|
||||
description = "The color scheme to use";
|
||||
example = "catppuccin-mocha";
|
||||
default = "catppuccin-mocha";
|
||||
};
|
||||
|
||||
font = mkOption {
|
||||
type = types.str;
|
||||
font = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The font to use";
|
||||
example = "JetBrainsMono Nerd Font Mono";
|
||||
default = "JetBrainsMono Nerd Font Mono";
|
||||
@ -28,23 +22,23 @@ with mylib.modules; {
|
||||
|
||||
# These options will be populated automatically.
|
||||
|
||||
hex = mkOption {
|
||||
type = types.attrs;
|
||||
hex = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Colors in \"RRGGBB\" hexadecimal format";
|
||||
};
|
||||
|
||||
hexString = mkOption {
|
||||
type = types.attrs;
|
||||
hexS = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Colors in \"#RRGGBB\" hexadecimal format";
|
||||
};
|
||||
|
||||
rgbString = mkOption {
|
||||
type = types.attrs;
|
||||
description = "Colors in \"RR,GG,BB\" decimal format";
|
||||
};
|
||||
|
||||
rgb = mkOption {
|
||||
type = types.attrs;
|
||||
rgb = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Colors in [RR GG BB] decimal format";
|
||||
};
|
||||
|
||||
rgbS = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Colors in \"RR,GG,BB\" decimal format";
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user