Esta página se muestra en inglés. Una traducción al español está en curso.
ScriptsJul 24, 2026·3 min de lectura

Nickel — Configuration Language with Contracts and Types

A configuration language written in Rust that uses contracts and gradual typing to produce correct, maintainable configuration files.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Nickel Config Language
Comando de instalación directa
npx -y tokrepo@latest install cc1553ef-86f9-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

Introduction

Nickel is a configuration language for generating JSON, YAML, and TOML with the safety of types and the flexibility of a dynamic language. Written in Rust, it provides gradual typing and contracts that validate values at evaluation time, catching errors before deployment.

What Nickel Does

  • Generates JSON, YAML, and TOML output from a single source language
  • Validates configuration values using contracts (runtime type checks)
  • Supports gradual typing so users can add type annotations incrementally
  • Provides functions, records, and merging for modular configuration
  • Catches constraint violations and type errors before configuration is deployed

Architecture Overview

Nickel programs are evaluated by an interpreter written in Rust. The pipeline parses source into an AST, performs optional static type checking, then reduces to normal form. Contracts are checked lazily when values cross boundaries. Record merging combines fragments with priority semantics. The result is serialized via nickel export.

Self-Hosting & Configuration

  • Single binary (nickel) with no external dependencies beyond a Rust toolchain or Nix
  • Files use the .ncl extension and can import other .ncl files by path
  • The LSP server (nickel-lang-lsp) provides editor integration for VS Code and Neovim
  • Libraries shared as packages imported via file paths or URLs
  • CI integration via nickel export and nickel typecheck

Key Features

  • Contracts enforce constraints on values (e.g., port numbers, non-empty strings) at evaluation time
  • Gradual typing allows mixing typed and untyped code in the same program
  • Record merging with priorities enables layered configuration (defaults, overrides, environment-specific)
  • First-class functions and polymorphism for reusable configuration abstractions
  • Deterministic evaluation produces reproducible output from the same inputs

Comparison with Similar Tools

  • CUE — Uses lattice-based types and unification; Nickel uses contracts with gradual typing
  • Jsonnet — Focused on JSON templating; Nickel adds a type system and contract validation
  • Dhall — Total functional language with strong guarantees; Nickel is more flexible with gradual typing
  • HCL — Domain-specific to Terraform; Nickel is general-purpose for any configuration target

FAQ

Q: What is the difference between types and contracts? A: Types are checked statically on annotated code. Contracts are checked at runtime when values cross boundaries, validating dynamic or untyped code.

Q: Can Nickel replace my YAML files? A: Yes. Write configuration in Nickel and use nickel export to produce YAML, JSON, or TOML for consumption by other tools.

Q: Is Nickel Turing-complete? A: Yes, unlike Dhall which is intentionally total. Nickel allows general recursion, though configuration programs are typically terminating.

Q: How mature is Nickel? A: Nickel reached 1.0 stability and is actively developed. The contract and type system are stable, and the language is used in production with NixOS integration.

Sources

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados