stylix: use image to generate color scheme with scheme = 'generate-from-image'
This commit is contained in:
parent
5fe892570c
commit
9721481a69
4 changed files with 15 additions and 14 deletions
|
|
@ -17,6 +17,7 @@ let
|
|||
"moonfly"
|
||||
"nord"
|
||||
"oxocarbon"
|
||||
"generate-from-image"
|
||||
];
|
||||
# schemes names in `pkgs.base16-schemes` that need a suffix
|
||||
needsSuffix = [
|
||||
|
|
@ -30,11 +31,6 @@ let
|
|||
];
|
||||
schemeName =
|
||||
if builtins.elem cfg.scheme needsSuffix then "${cfg.scheme}-${cfg.polarity}" else cfg.scheme;
|
||||
scheme =
|
||||
if builtins.elem cfg.scheme customSchemes then
|
||||
./schemes/${schemeName}.yaml
|
||||
else
|
||||
"${pkgs.base16-schemes}/share/themes/${schemeName}.yaml";
|
||||
|
||||
inherit (lib)
|
||||
mkDefault
|
||||
|
|
@ -51,13 +47,13 @@ in
|
|||
|
||||
options.stylix = {
|
||||
scheme = lib.mkOption {
|
||||
type = types.nullOr types.str;
|
||||
type = types.str;
|
||||
default = "dracula";
|
||||
description = ''
|
||||
Base16 color scheme name. Available options are:
|
||||
${toString validSchemes}
|
||||
|
||||
Set to `null` to generate a color scheme from `stylix.image`
|
||||
"generate-from-image" generates a color scheme from `stylix.image`
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
@ -68,15 +64,16 @@ in
|
|||
assertion = builtins.elem cfg.scheme validSchemes;
|
||||
message = "Stylix: Invalid colorscheme '${cfg.scheme}'. Available options: ${toString validSchemes}";
|
||||
}
|
||||
{
|
||||
assertion = (cfg.scheme != null) || (cfg.image != null);
|
||||
message = "Stylix: You need to set stylix.image if stylix.scheme is `null`";
|
||||
}
|
||||
];
|
||||
|
||||
stylix = {
|
||||
autoEnable = mkDefault true;
|
||||
base16Scheme = mkIf (cfg.scheme != null) scheme;
|
||||
base16Scheme = mkIf (cfg.scheme != "generate-from-image") (
|
||||
if builtins.elem cfg.scheme customSchemes then
|
||||
./schemes/${schemeName}.yaml
|
||||
else
|
||||
"${pkgs.base16-schemes}/share/themes/${schemeName}.yaml"
|
||||
);
|
||||
fonts = {
|
||||
monospace = mkDefault {
|
||||
package = pkgs.hack-font;
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@ let
|
|||
cfg = config.stylix;
|
||||
target = cfg.targets.nixvim;
|
||||
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib) mkIf optionalAttrs;
|
||||
in
|
||||
{
|
||||
config = mkIf cfg.enable {
|
||||
stylix.targets.nixvim.enable = false;
|
||||
programs.nixvim.colorschemes."${cfg.scheme}".enable = !target.enable;
|
||||
programs.nixvim.colorschemes = optionalAttrs (cfg.scheme != "generate-from-image") {
|
||||
"${cfg.scheme}".enable = !target.enable;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue