Why we built a Kubernetes compiler on Nix.
Kix uses Nix to track dependencies between resources, validate clusters without live API access, and give fast compiler feedback to engineers and coding agents.
Why Nix?
Kix definitions are written in the Nix language, part of a build system used for reproducible software for over 20 years. Kix relies on four capabilities from Nix and its standard library.
-
String context
Nix strings can carry hidden context paths alongside their text. Kix encodes resource identity on every output and endpoint details on network addresses. Nix preserves that context through string interpolation, and Kix carries it through ConfigMaps to order deployments and generate network policies.
-
Pure evaluation
In pure evaluation, Nix expressions cannot read environment variables, undeclared files, or live network APIs. Evaluating a definition never contacts a cluster, so
kix checkandkix buildrun without cluster credentials. -
Locked inputs
flake.lockpins the Kix library and external inputs by hash, and image digests are committed with the definition. The same commit builds the same resources. -
The module system
Cluster and package options have types and defaults, and settings from cluster profiles and clusters merge by the same rules everywhere.
Compiler feedback for people and agents
An agent can edit a Kix definition and use compiler errors to revise it. The resulting plan gives you a manageable view of the proposed change before deployment.
-
Agents write infrastructure code now.
Agents already write Kubernetes configuration for many teams, so they need the same checks that a person would use.
-
An agent needs fast, exact feedback.
Kix identifies the affected resource and explains the error, giving the agent something specific to correct.
-
You need something small enough to review.
You can review the results of
kix checkand the changes grouped by package fromkix diffbefore approving a deployment.
- agent or person edit the cluster definition
- kix $ kix check Names the resource and explains what to fix. back to the definition until it builds
- kix $ kix diff The plan, grouped by package.
- you review the plan Review the changes by package on the pull request.
- kix $ kix deploy In dependency order, waiting on readiness.