Zig FFI bindings for the Nickel configuration language.
Direct access to Nickel’s evaluation engine from Zig, via a Rust shim that wraps nickel-lang-core.
Unlike bunsenite (which embeds Nickel in a larger system), this provides standalone FFI access for any project that needs Nickel evaluation.
-
Evaluate Nickel source code and get JSON results
-
Type-check Nickel configurations
-
C FFI exports for use from Rust, Deno, ReScript, etc.
# Build the Rust shim first
cd shim && cargo build --release && cd ..
# Build the Zig library
zig build
# Or build both with:
zig build shim && zig buildconst nickel = @import("zig-nickel-ffi");
var ctx = try nickel.Context.init(allocator);
defer ctx.deinit();
// Evaluate Nickel source
const result = try ctx.eval(allocator, "{ x = 1 + 2, y = \"hello\" }");
defer allocator.free(result);
// result: { x = 3, y = "hello" }
// Type-check
const valid = try ctx.typecheck(allocator, "{ x : Number = 42 }");No C code involved - Zig declares extern "C" functions that link directly to Rust’s C-ABI exports.
┌─────────────────────────────────────┐
│ Your Application │
└─────────────────┬───────────────────┘
│
┌─────────────────▼───────────────────┐
│ zig-nickel-ffi (Zig) │
│ extern "C" declarations │
│ + high-level Zig API │
└─────────────────┬───────────────────┘
│ C ABI (calling convention only)
┌─────────────────▼───────────────────┐
│ nickel-ffi-shim (Rust) │
│ #[no_mangle] extern "C" exports │
└─────────────────┬───────────────────┘
│
┌─────────────────▼───────────────────┐
│ nickel-lang-core │
└─────────────────────────────────────┘
| Function | Description |
|---|---|
|
Create new evaluation context |
|
Free context |
|
Evaluate Nickel source, return result string |
|
Type-check source, return validity |
| Function | Description |
|---|---|
|
Create context |
|
Free context |
|
Evaluate, return string (caller frees) |
|
Type-check, return bool |
|
Free string from eval |
|
Get Nickel version |