chore: split render function into eval and render functions

allows access to more data of a nixlet module
This commit is contained in:
technofab 2025-04-04 15:56:15 +02:00
parent cd8ed7719e
commit 0b7f99f81e

View file

@ -44,11 +44,9 @@ with lib; rec {
description ? "", description ? "",
defaultProject ? null, defaultProject ? null,
... ...
}: let }: rec {
# TODO: just like with the values check the args here with the options system?
in {
inherit name version description path; inherit name version description path;
render = { eval = {
system, system,
project ? defaultProject, project ? defaultProject,
overrides ? ({...}: {}), overrides ? ({...}: {}),
@ -59,35 +57,43 @@ with lib; rec {
nixletArg = { nixletArg = {
inherit name project version description; inherit name project version description;
}; };
in in (kubenix.evalModules.${system} {
(kubenix.evalModules.${system} { module = {kubenix, ...}: {
module = {kubenix, ...}: { imports = with kubenix.modules; [
imports = with kubenix.modules; [ k8s
k8s helm
helm docker
docker files
files ({...}: let
({...}: let finalValues = mkValues "${path}/values.nix" {
finalValues = mkValues "${path}/values.nix" { rawValues = values;
rawValues = values; nixlet = nixletArg;
nixlet = nixletArg; };
}; in {
in { imports = [path];
imports = [path]; _module.args.nixlet =
_module.args.nixlet = {
{ values = finalValues;
values = finalValues; }
} // nixletArg;
// nixletArg; })
}) overrides
overrides ];
]; kubenix.project = project;
kubenix.project = project; };
}; });
}) render = {
.config system,
.kubernetes project ? defaultProject,
.resultYAML; overrides ? ({...}: {}),
values ? {},
}:
(eval {
inherit system project overrides values;
})
.config
.kubernetes
.resultYAML;
}; };
fetchNixlet = url: sha256: mkNixlet (builtins.fetchTarball {inherit url sha256;}); fetchNixlet = url: sha256: mkNixlet (builtins.fetchTarball {inherit url sha256;});