Nickel is the cheap configuration language.
Its purpose is to automate the generation of static configuration files - think JSON, YAML, XML, or your favorite data representation language - that are then fed to another system. It is designed to have a simple, well-understood core: it is in essence JSON with functions.
Nickel's salient traits are:
The motto guiding Nickel's design is:
Great defaults, design for extensibility
There should be a standard, clear path for common things. There should be no arbitrary restrictions that limit what you can do you the one day you need to go beyond.
Nickel is a good fit in any situation where you need to generate a complex configuration, be it for a single app, a machine, whole infrastructure, or a build system.
The motivating use cases are in particular: - The Nix package manager: Nix is a declarative package manager using its own language for specifying packages. Nickel is an evolution of the Nix language, while trying to overcome some of its limitations. - Infrastructure as code: infrastructure is becoming increasingly complex, requiring a rigorous approach to deployment, modification and configuration. This is where a declarative approach also shines, as adopted by Terraform, NixOps or Kubernetes, all requiring potentially complex generation of configuration. - Build systems: build systems (like Bazel) need a specification of the dependency graph.
Most aforementioned projects have their own bespoke configuration language. See Related projects and inspirations. In general, application-specific languages might suffer from feature creep, lack of abstractions or just feel ad hoc. Nickel buys you more for less.
Please follow the getting started guide for Nickel users on the nickel-lang
website. The instructions below are
either reproduced for this document to be relatively self-sufficient, or because
they are aimed toward hacking on the Nickel interpreter itself (e.g. building
the nickel-lang
crate documentation).
Start Nickel
nix run nickel
(which pulls it from the global flakes
registry), or with nix run github:tweag/nickel
(which pulls it
from the repo). You can use our binary cache to
prevent rebuilding a lot of packages. You pass in arguments with
an extra --
as in nix run nickel -- repl
,./nickel
, after building this repo, depending on the
location of the executable and passing in arguments directly,cargo run
after building, passing in arguments with
an extra --
as in cargo run -- -f program.ncl
.Run your first program:
console
$ ./nickel <<< 'let x = 2 in x + x'
4
Or load it from a file:
console
$ echo 'let s = "world" in "Hello, " ++ s' > program.ncl
$ ./nickel -f program.ncl
"Hello, world"
Start a REPL: ```console $ ./nickel repl nickel> let x = 2 in x + x 4
nickel>
``
Use
:help` for a list of available commands.
Export your configuration to JSON, YAML or TOML:
console
$ ./nickel export --format json <<< '{foo = "Hello, world!"}'
{
"foo": "Hello, world!"
}
Use nickel help
for a list of subcommands, and nickel help <subcommand>
for help about a specific subcommand.
Nickel has syntax highlighting plugins for Vim/Neovim, and VSCode. In-editor diagnostics, type hints, and auto-completion are provided by the Nickel Language Server. Please follow this guide to setup syntax highlighting and NLS.
console
$ nix-shell shell.nix
to be dropped in a shell, ready to build. You can use our binary
cache to prevent rebuilding a lot of
packages.console
$ cargo build
And voilĂ ! Generated files are placed in target/debug
.console
$ ln -S nickel target/debug/nickel
console
$ cargo test
The user manual is available on the nickel-lang.org
website, and in this
repository as a collection of Markdown files in doc/manual
.
To get the documentation of the nickel-lang
codebase itself:
console
$ cargo doc --no-deps
target/doc/nickel/index.html
in your browser.You can find examples in the ./examples
directory.
Nickel has been released in version 0.1
. This version should be functional, it
is intended to gather feedback and real-life testing. Nickel 0.1
isn't intended
to be used in production. The next steps we plan to work on are:
See RATIONALE.md for the design rationale and a more detailed comparison with a selection of these languages.