nixos-config/subprojects/bahaghari/lib/utils/tinted-theming.nix

33 lines
978 B
Nix
Raw Normal View History

2024-02-25 09:20:18 +00:00
{ 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.
2024-02-25 10:20:13 +00:00
generateOutputFromSchemes = { schemes ? { }, template }:
2024-02-25 09:20:18 +00:00
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; };
}