From f4b1db09f3f964483338fb65c2aea2b5695aef02 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sun, 25 Feb 2024 17:20:18 +0800 Subject: [PATCH] bahaghari/utils/tinted-theming: init --- subprojects/bahaghari/lib/tinted-theming.nix | 6 ---- subprojects/bahaghari/lib/utils/default.nix | 8 +++++ .../bahaghari/lib/utils/tinted-theming.nix | 32 +++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 subprojects/bahaghari/lib/utils/default.nix create mode 100644 subprojects/bahaghari/lib/utils/tinted-theming.nix diff --git a/subprojects/bahaghari/lib/tinted-theming.nix b/subprojects/bahaghari/lib/tinted-theming.nix index 6eed89d8..fb9eebbc 100644 --- a/subprojects/bahaghari/lib/tinted-theming.nix +++ b/subprojects/bahaghari/lib/tinted-theming.nix @@ -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: { }; diff --git a/subprojects/bahaghari/lib/utils/default.nix b/subprojects/bahaghari/lib/utils/default.nix new file mode 100644 index 00000000..4584d2a6 --- /dev/null +++ b/subprojects/bahaghari/lib/utils/default.nix @@ -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; +} diff --git a/subprojects/bahaghari/lib/utils/tinted-theming.nix b/subprojects/bahaghari/lib/utils/tinted-theming.nix new file mode 100644 index 00000000..360c9f7e --- /dev/null +++ b/subprojects/bahaghari/lib/utils/tinted-theming.nix @@ -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 < "$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; }; +}