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

30 lines
934 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 {
2024-02-25 09:20:18 +00:00
# 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 {
2024-02-25 09:20:18 +00:00
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;
};
2024-02-25 09:20:18 +00:00
}