mirror of
https://github.com/danth/stylix
synced 2024-09-20 06:11:56 +00:00
parent
989fe8857c
commit
8174101c22
2 changed files with 52 additions and 29 deletions
11
README.md
11
README.md
|
@ -58,9 +58,18 @@ a NixOS module; how to do this is shown in the example above.
|
|||
# A colorscheme will be chosen automatically based on your wallpaper.
|
||||
stylix.image = ./wallpaper.png;
|
||||
|
||||
# Use this option to force a light or dark theme.
|
||||
# Use this option to force a light or dark theme to be chosen.
|
||||
stylix.polarity = "light";
|
||||
|
||||
# You can override parts of the scheme by hand:
|
||||
stylix.palette = {
|
||||
base00 = "eeeeee";
|
||||
base05 = "111111";
|
||||
};
|
||||
|
||||
# Or replace it with a scheme from base16:
|
||||
stylix.base16Scheme = "${base16-schemes}/gruvbox-dark-hard.yaml";
|
||||
|
||||
# Select your preferred fonts, or use these defaults:
|
||||
stylix.fonts = {
|
||||
serif = {
|
||||
|
|
|
@ -9,13 +9,18 @@ let
|
|||
paletteJSON = pkgs.runCommand "palette.json" { } ''
|
||||
${palette-generator}/bin/palette-generator ${cfg.polarity} ${cfg.image} $out
|
||||
'';
|
||||
generatedPalette = importJSON paletteJSON;
|
||||
|
||||
palette = importJSON paletteJSON // {
|
||||
paletteOverrides = filterAttrs (_: color: color != null) cfg.palette;
|
||||
|
||||
metadata = {
|
||||
author = "Stylix";
|
||||
scheme = "Stylix";
|
||||
slug = "stylix";
|
||||
};
|
||||
|
||||
stylixPalette = generatedPalette // paletteOverrides // metadata;
|
||||
|
||||
in {
|
||||
options.stylix = {
|
||||
polarity = mkOption {
|
||||
|
@ -40,35 +45,44 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
/* TODO: Implement manual palette
|
||||
palette = genAttrs [
|
||||
"base00"
|
||||
"base01"
|
||||
"base02"
|
||||
"base03"
|
||||
"base04"
|
||||
"base05"
|
||||
"base06"
|
||||
"base07"
|
||||
"base08"
|
||||
"base09"
|
||||
"base0A"
|
||||
"base0B"
|
||||
"base0C"
|
||||
"base0D"
|
||||
"base0E"
|
||||
"base0F"
|
||||
] (name:
|
||||
mkOption {
|
||||
description = "Hexadecimal color value for ${name}.";
|
||||
default = null;
|
||||
defaultText = "Automatically selected from the background image.";
|
||||
type = types.nullOr (types.strMatching "[0-9a-fA-F]{6}");
|
||||
});
|
||||
*/
|
||||
palette = genAttrs [
|
||||
"base00" "base01" "base02" "base03" "base04" "base05" "base06" "base07"
|
||||
"base08" "base09" "base0A" "base0B" "base0C" "base0D" "base0E" "base0F"
|
||||
] (base: mkOption {
|
||||
description = ''
|
||||
Hexadecimal color value for ${base}.
|
||||
|
||||
These options can be used to override a section of the automatically
|
||||
generated palette, while keeping other parts. For example, you can
|
||||
select the background and text colors by setting bases 00 to 07, while
|
||||
keeping the accent colors automatic.
|
||||
|
||||
See <literal>stylix.base16Scheme</literal> for importing an entire
|
||||
scheme.
|
||||
'';
|
||||
default = null;
|
||||
defaultText = "Automatically selected from the background image.";
|
||||
type = types.nullOr (types.strMatching "[0-9a-fA-F]{6}");
|
||||
});
|
||||
|
||||
base16Scheme = mkOption {
|
||||
description = ''
|
||||
A scheme following the base16 standard.
|
||||
|
||||
This can be a path to a file, a string of YAML, or an attribute set.
|
||||
|
||||
Setting this option will completely disable the automatic palette
|
||||
generator, and use these colors instead.
|
||||
'';
|
||||
default = null;
|
||||
type = with types; nullOr (oneOf [ path lines attrs ]);
|
||||
};
|
||||
};
|
||||
|
||||
# This attrset can be used like a function too, see
|
||||
# https://github.com/SenchoPens/base16.nix#mktheme
|
||||
config.lib.stylix.colors = base16.mkSchemeAttrs palette;
|
||||
config.lib.stylix.colors =
|
||||
if cfg.base16Scheme != null
|
||||
then base16.mkSchemeAttrs cfg.base16Scheme
|
||||
else base16.mkSchemeAttrs stylixPalette;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue