@@ -26,7 +26,7 @@ We will **replace Tera templates with Nickel configuration language** using a **
2626
2727### Architecture: Three-Stage Pipeline
2828
29- ```
29+ ``` text
3030Nickel Template (.ncl)
3131 ↓ (nickel export --format json)
3232 ↓
@@ -102,6 +102,7 @@ export def nickel_to_yaml [template: path, output: path]: nothing {
102102** Rejected** : Custom Rust code to wrap Nickel evaluation
103103
104104** Rationale** :
105+
105106- Nickel CLI is proven and well-maintained
106107- Unnecessary Rust code adds maintenance burden
107108- Shell scripts are simpler and more transparent
@@ -110,7 +111,7 @@ export def nickel_to_yaml [template: path, output: path]: nothing {
110111
111112### Template Organization
112113
113- ```
114+ ``` text
114115provisioning/templates/
115116├── prometheus/config.ncl # Prometheus YAML
116117├── tracker/config.ncl # Tracker TOML
@@ -131,23 +132,27 @@ provisioning/templates/
131132Each format has specialized renderers:
132133
133134** YAML Conversion** (via yq):
135+
134136``` bash
135137nickel export --format json template.ncl | yq -P . > output.yml
136138```
137139
138140** HCL Conversion** (custom jq builder):
141+
139142``` bash
140143nickel export --format json template.ncl | jq -r ' to_entries[] |
141144 "\(.key) = \(.value | @json)"' > output.tfvars
142145```
143146
144147** ENV Conversion** (custom jq builder):
148+
145149``` bash
146150nickel export --format json template.ncl | jq -r ' to_entries[] |
147151 "\(.key)=\(.value)"' > output.env
148152```
149153
150154** TOML Conversion** (custom jq builder):
155+
151156``` bash
152157nickel export --format json template.ncl | jq -r ' to_entries[] |
153158 "\(.key) = \(.value | @json)"' > output.toml
@@ -175,68 +180,81 @@ Three-layer validation ensures configuration correctness:
175180### Positive
176181
177182** Simplicity** :
183+
178184- No custom Rust infrastructure needed
179185- Shell scripts are transparent and composable
180186- Fewer dependencies to maintain
181187
182188** Type Safety** :
189+
183190- Nickel schemas provide compile-time checks
184191- Validators enforce constraints at evaluation time
185192- Structured error messages on validation failure
186193
187194** No Delimiter Conflicts** :
195+
188196- Nickel syntax doesn't conflict with Ansible/Jinja2/Kubernetes
189197- Template readability improved (no ` {% raw %} ` blocks needed)
190198- Easier to embed in other formats
191199
192200** Standards-Based** :
201+
193202- Uses standard CLI tools (jq, yq, nickel)
194203- Follows Unix philosophy
195204- Scripts can be called from any language or tool
196205
197206** Better Error Messages** :
207+
198208- Nickel provides context-aware error reporting
199209- Validators give specific constraint violation messages
200210- JSON structure makes errors debuggable
201211
202212### Negative
203213
204214** Learning Curve** :
215+
205216- Team must learn Nickel language (different from Jinja2)
206217- Different pattern for composing configurations
207218
208219** Potential Duplication** :
220+
209221- Some configuration repeated if not factored into shared modules
210222- Requires discipline to keep templates DRY
211223
212224** Format Conversion Complexity** :
225+
213226- Custom jq/Nu code needed for non-standard formats
214227- TOML conversion has limitations with nested structures
215228- Requires testing for each format
216229
217230** Gradual Integration** :
231+
218232- Cannot immediately remove all Tera templates
219233- Dual maintenance period during transition
220234- Existing Rust code expecting Tera must be adapted
221235
222236### Mitigation Strategies
223237
224238** Documentation** :
239+
225240- Comprehensive template examples
226241- Guidelines for creating new templates
227242- Architecture decision record (this document)
228243
229244** Validation** :
245+
230246- Extensive E2E tests ensure generated configs work
231247- Format-specific validators catch conversion errors
232248- Pre-commit checks validate Nickel syntax
233249
234250** Code Review** :
251+
235252- Review template changes for proper structure
236253- Ensure validators are applied to constrained fields
237254- Check for DRY principle in schema/validator definitions
238255
239256** Gradual Transition** :
257+
240258- Keep existing Tera code until Nickel replaces all use cases
241259- Run both systems in parallel during transition
242260- Incremental migration per template type
@@ -246,6 +264,7 @@ Three-layer validation ensures configuration correctness:
246264### 1. Continue with Tera
247265
248266** Rejected** : Doesn't solve core problems:
267+
249268- Delimiter conflicts remain
250269- No type safety mechanism
251270- Tight Rust coupling continues
@@ -254,6 +273,7 @@ Three-layer validation ensures configuration correctness:
254273### 2. Rust Library Wrapper Around Nickel
255274
256275Example (rejected):
276+
257277``` rust
258278struct NickelTemplateRenderer {
259279 template_path : PathBuf ,
@@ -268,13 +288,15 @@ impl NickelTemplateRenderer {
268288```
269289
270290** Rejected Reasons** :
291+
271292- Unnecessary abstraction layer
272293- Adds maintenance burden
273294- Hides CLI availability
274295- Duplicates work already done by nickel CLI
275296- Reduces transparency
276297
277298** Rationale for CLI-first approach** :
299+
278300- Nickel CLI is the proven tool
279301- Keep infrastructure simple
280302- Let shell scripts handle orchestration
@@ -283,6 +305,7 @@ impl NickelTemplateRenderer {
283305### 3. KCL (Kyverno Configuration Language)
284306
285307** Rejected** :
308+
286309- Primarily designed for Kubernetes validation
287310- Less suitable for multi-format configuration generation
288311- Smaller ecosystem than Nickel
@@ -291,6 +314,7 @@ impl NickelTemplateRenderer {
291314### 4. CUE Language
292315
293316** Rejected** :
317+
294318- Complex syntax, steeper learning curve
295319- Less familiar to team
296320- Overkill for our configuration needs
@@ -304,6 +328,7 @@ impl NickelTemplateRenderer {
304328## Implementation Status
305329
306330** Completed** :
331+
307332- 9 Nickel templates created and tested
308333- Nushell rendering scripts (5 variants: generic, yaml, toml, hcl, env)
309334- Bash fallback scripts for portability
@@ -312,10 +337,12 @@ impl NickelTemplateRenderer {
312337- Validation at Nickel evaluation time
313338
314339** Partially Complete** :
340+
315341- TOML conversion works for simple structures (tracker template needs refinement for complex nested arrays)
316342- Rust integration pending (can call scripts via ` Command::new("nu") ` or ` Command::new("bash") ` )
317343
318344** Future** :
345+
319346- Incremental Rust integration for ProjectGenerator (minimal, script-calling only)
320347- Migration away from Tera templates as Nickel coverage expands
321348- Performance profiling and optimization if needed
0 commit comments