bahaghari/utils/tinted-theming: init

This commit is contained in:
Gabriel Arazas 2024-02-25 17:20:18 +08:00
parent df345c8b51
commit f4b1db09f3
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
3 changed files with 40 additions and 6 deletions

View File

@ -11,12 +11,6 @@ let
(pkgs.lib.count (name: pkgs.lib.elem name schemeNames) paletteNames) == i;
in
{
# TODO: Return a derivation containing all of the template output from the
# given schemes.
generateOutputFromSchemes = schemes: template:
pkgs.runCommand "generate-templates" { } ''
'';
# TODO: Return a Nix object to generate a Tinted Theming color scheme from an
# image.
generateScheme = image: { };

View File

@ -0,0 +1,8 @@
{ config, lib, pkgs, bahaghariLib }:
let
callLib = path: import path { inherit config lib pkgs bahaghariLib; };
in
{
tinted-theming = callLib ./tinted-theming.nix;
}

View File

@ -0,0 +1,32 @@
{ config, lib, pkgs, bahaghariLib }:
let
cfg = config.bahaghari.tinted-theming;
in
rec {
# Return a derivation containing all of the template output from the given
# schemes.
generateOutputFromSchemes = { schemes ? {}, template }:
let
schemesDir = pkgs.runCommand "aggregate-schemes" { }
''
mkdir -p "$out"
${
lib.concatMapStrings (scheme: ''
echo <<EOF > "$out/${scheme.name}.yml"
${bahaghariLib.toYAML scheme}
EOF
'') lib.attrNames schemes
}
'';
in
pkgs.runCommand "generate-templates" { } (cfg.builder.script {
inherit schemesDir;
templateDir = template;
});
# Return a derivation containing the generated template with the given
# builder script with all of the Tinted Theming schemes.
generateOutputFromAllSchemes = { template }:
generateOutputFromSchemes { schemes = cfg.schemes; inherit template; };
}