Compare commits

..

4 commits

Author SHA1 Message Date
Allsimon
16fbe4d684 Merge branch 'mustache' into 'main'
feat(generator): add Mustache

See merge request TECHNOFAB/soonix!4
2026-01-26 20:24:21 +00:00
asimon
26e79ede19 feat(generator): add Mustache 2026-01-26 21:23:49 +01:00
7e3efd400c Merge branch 'gomplate' into 'main'
fix(generator): replace gotmpl with gomplate

See merge request TECHNOFAB/soonix!5
2026-01-26 14:50:22 +01:00
asimon
a8acaf7143 fix(generator): replace gotmpl with gomplate 2026-01-25 12:15:49 +01:00
7 changed files with 15 additions and 13 deletions

View file

@ -53,7 +53,7 @@ use the `devshellModule` for easy integration, see the docs for more.
- **`nix`**: Convert Nix data to JSON, YAML, TOML, INI, XML formats - **`nix`**: Convert Nix data to JSON, YAML, TOML, INI, XML formats
- **`string`**: Output raw string content with optional executable permissions - **`string`**: Output raw string content with optional executable permissions
- **`derivation`**: Use existing Nix derivations as file content - **`derivation`**: Use existing Nix derivations as file content
- **`gotmpl`**: Advanced Go template rendering via gomplate - **`gomplate`**: Advanced Go template rendering via gomplate
- **`jinja`**: Python Jinja2 template rendering - **`jinja`**: Python Jinja2 template rendering
- **`mustache`**: Mustache template rendering - **`mustache`**: Mustache template rendering

View file

@ -19,7 +19,7 @@ Soonix helps you:
- **nix**: Convert Nix data to JSON, YAML, TOML, INI, XML formats - **nix**: Convert Nix data to JSON, YAML, TOML, INI, XML formats
- **string**: Output raw string content with optional executable permissions - **string**: Output raw string content with optional executable permissions
- **derivation**: Use existing Nix derivations as file content - **derivation**: Use existing Nix derivations as file content
- **gotmpl**: Advanced Go template rendering via gomplate - **gomplate**: Advanced Go template rendering via gomplate
- **jinja**: Python Jinja2 template rendering - **jinja**: Python Jinja2 template rendering
- **mustache**: Mustache template rendering - **mustache**: Mustache template rendering
@ -64,7 +64,7 @@ Automatically manage .gitignore entries for generated files to keep your reposit
dockerfile = { dockerfile = {
output = "Dockerfile"; output = "Dockerfile";
generator = "gotmpl"; generator = "gomplate";
data = { data = {
baseImage = "node:18-alpine"; baseImage = "node:18-alpine";
port = 3000; port = 3000;

View file

@ -100,7 +100,7 @@ Use Go templates for more complex file generation:
hooks = { hooks = {
dockerfile = { dockerfile = {
output = "Dockerfile"; output = "Dockerfile";
generator = "gotmpl"; generator = "gomplate";
data = { data = {
baseImage = "node:18-alpine"; baseImage = "node:18-alpine";
workdir = "/app"; workdir = "/app";
@ -331,7 +331,7 @@ in {
hooks = { hooks = {
kubernetes-manifest = { kubernetes-manifest = {
output = "k8s/deployment.yaml"; output = "k8s/deployment.yaml";
generator = "gotmpl"; generator = "gomplate";
data = { data = {
app = { app = {
name = "my-app"; name = "my-app";

View file

@ -50,7 +50,7 @@
# only a passthru # only a passthru
derivation = {data, ...}: data; derivation = {data, ...}: data;
gotmpl = { gomplate = {
name, name,
opts, opts,
data, data,
@ -112,7 +112,9 @@
in in
runCommand name { runCommand name {
buildInputs = [mustache]; buildInputs = [mustache];
} "mustache ${dataJson} ${template} > $out"; } ''
mustache ${dataJson} ${template} > $out
'';
}; };
buildAllFiles = files: buildAllFiles = files:

View file

@ -30,7 +30,7 @@ in {
}; };
generator = mkOption { generator = mkOption {
type = types.enum ["nix" "string" "derivation" "gotmpl" "jinja" "mustache" "template"]; type = types.enum ["nix" "string" "derivation" "gomplate" "jinja" "mustache" "template"];
description = '' description = ''
Which engine to use for content generation. Which engine to use for content generation.
''; '';

View file

@ -19,10 +19,10 @@
}; };
}; };
gomplate = { gomplate = {
output = "gotmpl"; output = "gomplate";
generator = "gotmpl"; generator = "gomplate";
data.hello = "world"; data.hello = "world";
opts.template = ./fixtures/gotmpl_template; opts.template = ./fixtures/gomplate_template;
}; };
jinja = { jinja = {
output = "jinja"; output = "jinja";
@ -54,8 +54,8 @@ in {
assert "-f ${finalFiles}/out/test.json" "should exist" assert "-f ${finalFiles}/out/test.json" "should exist"
assert_file_contains ${finalFiles}/out/test.json "soonix-test" assert_file_contains ${finalFiles}/out/test.json "soonix-test"
assert "-f ${finalFiles}/gotmpl" "should exist" assert "-f ${finalFiles}/gomplate" "should exist"
assert_file_contains ${finalFiles}/gotmpl "Hello world" assert_file_contains ${finalFiles}/gomplate "Hello world"
assert "-f ${finalFiles}/jinja" "should exist" assert "-f ${finalFiles}/jinja" "should exist"
assert_file_contains ${finalFiles}/jinja "Hello world" assert_file_contains ${finalFiles}/jinja "Hello world"