Don't build a palette which isn't used

If a scheme is specified manually then this avoids generating the
automatic scheme. See #13
This commit is contained in:
Daniel Thwaites 2022-10-30 14:17:28 +00:00
parent 5b45ba84b6
commit 655fda7894
No known key found for this signature in database
GPG key ID: D8AFC4BF05670F9D

View file

@ -11,6 +11,12 @@ let
'';
generatedPalette = importJSON paletteJSON;
generatedScheme = cfg.palette // {
author = "Stylix";
scheme = "Stylix";
slug = "stylix";
};
in {
options.stylix = {
polarity = mkOption {
@ -63,11 +69,7 @@ in {
This can be a path to a file, a string of YAML, or an attribute set.
'';
type = with types; oneOf [ path lines attrs ];
default = cfg.palette // {
author = "Stylix";
scheme = "Stylix";
slug = "stylix";
};
default = generatedScheme;
defaultText = literalDocBook ''
The colors defined in <literal>stylix.palette</literal>.
@ -87,7 +89,7 @@ in {
# garbage collection, so future configurations can be evaluated without
# having to generate the palette again. The generator is not kept, only
# the palette which came from it, so this uses very little disk space.
"stylix/palette.json".source = paletteJSON;
"stylix/palette.json".source = mkIf (cfg.base16Scheme == generatedScheme) paletteJSON;
# We also provide a HTML version which is useful for viewing the colors
# during development.