Prevent scheme generation from running when result is not used (#56)
This commit is contained in:
parent
6d3a046d17
commit
efb734ff43
4 changed files with 55 additions and 13 deletions
|
|
@ -7,7 +7,14 @@ args:
|
|||
config = {
|
||||
xdg.configFile = {
|
||||
# See ../nixos/palette.nix for the rational behind these two options
|
||||
"stylix/palette.json".source = config.stylix.generated.json;
|
||||
"stylix/generated.json".source = config.lib.stylix.scheme {
|
||||
template = builtins.readFile ../palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
"stylix/palette.json".source = config.lib.stylix.colors {
|
||||
template = builtins.readFile ../palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
"stylix/palette.html".source = config.lib.stylix.colors {
|
||||
template = builtins.readFile ../palette.html.mustache;
|
||||
extension = ".html";
|
||||
|
|
|
|||
|
|
@ -10,7 +10,18 @@ args:
|
|||
# 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 = config.stylix.generated.json;
|
||||
# The extra indirection should prevent the palette generator from running
|
||||
# when the theme is manually specified. generated.json is necessary in
|
||||
# the presence of overrides.
|
||||
"stylix/generated.json".source = config.lib.stylix.scheme {
|
||||
template = builtins.readFile ../palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
|
||||
"stylix/palette.json".source = config.lib.stylix.colors {
|
||||
template = builtins.readFile ../palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
|
||||
# We also provide a HTML version which is useful for viewing the colors
|
||||
# during development.
|
||||
|
|
|
|||
21
stylix/palette.json.mustache
Normal file
21
stylix/palette.json.mustache
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"base00": "{{{base00}}}",
|
||||
"base01": "{{{base01}}}",
|
||||
"base02": "{{{base02}}}",
|
||||
"base03": "{{{base03}}}",
|
||||
"base04": "{{{base04}}}",
|
||||
"base05": "{{{base05}}}",
|
||||
"base06": "{{{base06}}}",
|
||||
"base07": "{{{base07}}}",
|
||||
"base08": "{{{base08}}}",
|
||||
"base09": "{{{base09}}}",
|
||||
"base0A": "{{{base0A}}}",
|
||||
"base0B": "{{{base0B}}}",
|
||||
"base0C": "{{{base0C}}}",
|
||||
"base0D": "{{{base0D}}}",
|
||||
"base0E": "{{{base0E}}}",
|
||||
"base0F": "{{{base0F}}}",
|
||||
"scheme": "Stylix",
|
||||
"author": "Stylix",
|
||||
"slug": "stylix"
|
||||
}
|
||||
|
|
@ -8,16 +8,18 @@ let
|
|||
|
||||
cfg = config.stylix;
|
||||
|
||||
paletteJSON = pkgs.runCommand "palette.json" { } ''
|
||||
${palette-generator}/bin/palette-generator ${cfg.polarity} ${cfg.image} $out
|
||||
'';
|
||||
generatedPalette = importJSON paletteJSON;
|
||||
|
||||
generatedScheme = generatedPalette // {
|
||||
author = "Stylix";
|
||||
scheme = "Stylix";
|
||||
slug = "stylix";
|
||||
};
|
||||
paletteJSON = let
|
||||
generatedJSON = pkgs.runCommand "palette.json" { } ''
|
||||
${palette-generator}/bin/palette-generator ${cfg.polarity} ${cfg.image} $out
|
||||
'';
|
||||
palette = importJSON generatedJSON;
|
||||
scheme = base16.mkSchemeAttrs palette;
|
||||
json = scheme {
|
||||
template = builtins.readFile ./palette.json.mustache;
|
||||
extension = ".json";
|
||||
};
|
||||
in json;
|
||||
generatedScheme = importJSON paletteJSON;
|
||||
|
||||
override =
|
||||
(if cfg.base16Scheme == fromOs [ "base16Scheme" ] {}
|
||||
|
|
@ -84,7 +86,7 @@ in {
|
|||
description = "The imported json";
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
default = generatedPalette;
|
||||
default = generatedScheme;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -124,5 +126,6 @@ in {
|
|||
# This attrset can be used like a function too, see
|
||||
# https://github.com/SenchoPens/base16.nix#mktheme
|
||||
lib.stylix.colors = (base16.mkSchemeAttrs cfg.base16Scheme).override override;
|
||||
lib.stylix.scheme = base16.mkSchemeAttrs cfg.base16Scheme;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue