Reference / Clusters and instances
kix.toml
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
kix.toml is an optional configuration file placed beside flake.nix at the root of a Kix project. It chooses the project’s builder: whether Kix evaluates clusters with the Nix in the Kix runtime and Kix’s local store (builder = "kix", the default) or with the machine’s installed Nix and /nix/store (builder = "nix"). It can also assign clusters to different Kix library inputs in the [versions] table, so one project can keep clusters on different versions of Kix. Because kix.toml lives in the repository, every contributor and CI job uses the same settings without passing extra flags or environment variables. Version numbers live in flake.lock, as The version of Kix explains.
Location and format
Section titled “Location and format”Kix looks for kix.toml in the directory named by --flake (by default ., the current working directory). When --flake is a remote flake reference such as github:org/repo rather than a local directory, Kix uses the default builder ("kix").
1builder = "nix"The file and its settings are optional. An absent kix.toml or an empty kix.toml is equivalent to:
1builder = "kix"kix.toml accepts only keys that the installed version of Kix recognizes. In this version of Kix, the valid settings are builder, library, the [upgrade] table, and the [versions] table. Unknown keys, unknown builder names, a kix line, and TOML syntax errors stop the command before evaluation starts. In a project with a [versions] table, the Kix version pinned by kix validates every setting in kix.toml, while older Kix versions in the project ignore settings they do not recognize.
The version of Kix
Section titled “The version of Kix”kix.toml stores no version numbers. Every version of Kix in a project comes from a release tag in flake.lock, such as v0.10.0 for Kix 0.10.0. By default, every cluster uses the kix input. Adding a [versions] table lets you assign clusters to additional inputs so some clusters stay on an older version while others upgrade. Before Kix parses its command line, it checks flake.lock for the cluster’s input (or kix when the command names no cluster) and runs the matching version, installing it first when needed. See Choose the version of Kix for a project.
A kix line in kix.toml stops every command with error [K4476]. Delete the line, run kix upgrade --to <version> with the version the line named to pin the project to it, then run kix upgrade to move to a newer version and see what it changes. Upgrade a project from Kix 0.9 gives each step.
The library setting
Section titled “The library setting”library says where the project’s Kix library comes from. It takes two values:
library = "input", the default: the Kix library comes from the flake input namedkix(plus any additional inputs listed in[versions]), and each input’s release tag inflake.lockis the version of Kix its clusters run. Leaving the setting out means the same.library = "self": the project’s own flake provides the Kix library, as the Kix repository does.
1library = "self"With "self" the project has no kix input and no release version. Kix runs the version you started, prints a note that the project uses a development Kix library, and compares no versions. Setting library = "self" together with a [versions] table is an error, and any other library value stops the command with an error that names both values.
The builder setting
Section titled “The builder setting”| Value | Status | Nix binary and store | How Helm charts are rendered |
|---|---|---|---|
"kix" | Default | The nix in the Kix runtime (2.35.4), with Kix’s local store at $XDG_CACHE_HOME/kix/store (or ~/.cache/kix/store, overridden by KIX_STORE_ROOT) | Kix runs the helm programs in the Kix runtime outside Nix and writes chart tarballs and rendered JSON into Kix’s local store |
"nix" | Supported | nix and nix-store from PATH, using /nix/store and the machine’s nix.conf | Nix fetches charts as fixed-output derivations and runs helm template inside ordinary Nix builds during evaluation |
"remote" | Reserved | Remote build service (not yet implemented) | Refused by this version of Kix |
builder = "kix" (default)
Section titled “builder = "kix" (default)”When builder is "kix" (or when kix.toml is omitted), Kix runs the nix, nix-store, helm, kubectl, and sops binaries from the Kix runtime in libexec/kix/. It writes evaluated manifests and rendered Helm charts into Kix’s local store at $XDG_CACHE_HOME/kix/store (or ~/.cache/kix/store when XDG_CACHE_HOME is unset).
This mode requires no Nix installation on the machine, no Nix daemon, no /nix directory, no root access, and no Linux user namespaces.
builder = "nix"
Section titled “builder = "nix"”When kix.toml sets builder = "nix", Kix runs nix and nix-store from PATH against the machine’s /nix/store. It inherits the machine’s and user’s Nix configuration (nix.conf), including binary caches (substituters), remote build machines (builders), and access-tokens.
Use builder = "nix" when your project needs any of the following:
- Shared Nix binary caches or remote builders configured in
nix.conf. - Plain
nix buildornix flake checkon clusters that include Helm charts. - The
packages.<system>.cluster-<name>-activationflake output for scripts or CI pipelines that build activations directly withnix build.
Under builder = "nix", both kix and plain nix commands render Helm charts inside ordinary Nix derivations using the official Helm release binary pinned in kix/lib/helm-versions.json (4.3.1 for helmVersion = "4" and 3.19.1 for helmVersion = "3", matching the binaries shipped in libexec/kix/). Both builders pass the same helm template flags, so a chart renders the same way under either builder. For the Helm clusters in the Kix repository, both builders give identical manifests.
Even when builder = "nix", Kix still runs kubectl, sops, and any direct CLI helm invocations from the Kix runtime in libexec/kix/ rather than PATH.
builder = "remote" (reserved)
Section titled “builder = "remote" (reserved)”builder = "remote" is reserved for a build service that builds the project on another machine. This version of Kix refuses it:
1<path>/kix.toml sets builder = "remote", but remote builders are not supported yet. Set builder = "kix", or remove the settingThe [upgrade] table
Section titled “The [upgrade] table”The [upgrade] table configures how kix upgrade selects target releases when upgrading an input:
1[upgrade]2min-age = "7d"| Key | Value | Effect |
|---|---|---|
min-age | A number of days, such as "7d" | kix upgrade picks only releases at least this old, by their release date. |
The [versions] table
Section titled “The [versions] table”The [versions] table maps flake input names from flake.nix to lists of cluster names, letting one project keep clusters on different versions of Kix. Each key matches an input in flake.nix (kix for the newest version, plus an input such as kix-stable for each older version). Version tags stay in flake.nix and flake.lock; kix.toml stores only which clusters use each input. Projects without [versions] use kix for every cluster.
flake.nix passes only inputs.kix to mkFlake; nothing in outputs needs to reference the other Kix inputs. When a command targets a cluster assigned to another input, Kix runs the version pinned by that input in flake.lock and overrides kix with that input during evaluation. Project-wide commands that take no cluster name (kix list clusters, kix list packages with no cluster, kix doctor, kix pin, and kix status with no cluster) run the version pinned by kix.
1# flake.nix (version numbers are examples)2{3 inputs.kix.url = "github:kix-run/kix/v0.14.2";4 inputs.kix-stable.url = "github:kix-run/kix/v0.12.3"; # held back5
6 outputs = inputs: inputs.kix.lib.mkFlake {7 inherit inputs;8 clusters.staging = ./clusters/staging.nix;9 clusters.prod = ./clusters/prod.nix;10 };11}1[versions]2kix = ["staging"]3kix-stable = ["prod"]- List every cluster. Once
[versions]exists, every cluster inflake.nixmust appear in the table. kixpins the newest release. No other input in[versions]may pin a newer release thankix. Inputs pointing to a local folder or branch have no release version and are skipped in this comparison.- One input per cluster. Each cluster may appear under one input only.
- Distinct names. A cluster may not share a name with any input in
[versions], and may not be namedkix. - Every key is a locked input. Each key in
[versions]must be declared inflake.nixand locked inflake.lock. Lock a new input withkix upgrade <input>. - Incompatible with
library = "self".library = "self"and[versions]cannot be used together. - Every version must recognize
[versions]. Every version of Kix in the project must support[versions](Kix 0.10.0 or later). Earlier versions rejectversionsas an unknown setting inkix.toml.
Shared files across versions
Section titled “Shared files across versions”Every cluster in the repository shares flake.nix, kix.toml, and imported .nix modules:
- Shared modules and helpers imported by multiple clusters must stay compatible with every Kix version in the project.
- The Kix version pinned by
kixvalidates allkix.tomlsettings andmkFlakearguments, failing on unknown keys or arguments. - Older Kix versions in
[versions]ignore unknownkix.tomlkeys and unknownmkFlakearguments, while still rejecting invalid values for settings they recognize.
Tracking kix.toml in Git
Section titled “Tracking kix.toml in Git”Nix flakes only see files that Git tracks. When kix.lib.mkFlake evaluates your flake, it reads ${inputs.self}/kix.toml inside Nix and exposes the chosen builder at legacyPackages.<system>.kixConfig.builder.
Before evaluating a cluster, kix compares the kix.toml file on disk with legacyPackages.<system>.kixConfig.builder. If you create kix.toml with builder = "nix" and do not stage it in Git, Nix does not copy kix.toml into the flake source tree, the Kix library falls back to "kix", and kix stops with an error:
1./kix.toml is not tracked by Git, so Nix ignores it. Run `git add kix.toml`Stage kix.toml whenever you add or change it:
❱ git add kix.toml Two other conditions must hold for the CLI and the flake library to agree:
flake.nixmust passinputs(which includesself) tokix.lib.mkFlake { inherit inputs; ... }, somkFlakecan locate${inputs.self}/kix.toml.- The
kixflake input locked inflake.lockmust be new enough to exposekixConfig. If the locked library predateskix.tomlsupport,kixprompts you to runkix upgrade --to <version>with its own version.
Requirements for builder = "nix"
Section titled “Requirements for builder = "nix"”When a project sets builder = "nix", the machine running kix must meet these requirements:
- Nix 2.24 or later on
PATH. The Kix library uses the|>pipe operator (pipe-operators), which Nix added in 2.24. - Upstream Nix, not Lix. Lix reports
(Lix, like Nix)innix --versionand is refused because this builder relies on upstream Nix’s flake and pipe-operator behavior. allow-import-from-derivationenabled (true). This is the default in Nix. Whenbuilder = "nix",scope.helm.importChartandkix.helmChartbuild a derivation that runshelm templateand import the rendered JSON during evaluation (Import From Derivation, or IFD). Ifallow-import-from-derivationis set tofalseinnix.conf, evaluating a cluster that uses Helm charts fails.- No
trusted-usersrequirement. Thenixbuilder uses ordinary fixed-output derivations for chart downloads and standard derivations for chart rendering. Your user account does not need to be listed intrusted-userson the Nix daemon. KIX_STORE_ROOTmust be unset.KIX_STORE_ROOTonly redirects the local store of thekixbuilder. IfKIX_STORE_ROOTis set in the environment for a project withbuilder = "nix",kixstops and asks you to unsetKIX_STORE_ROOT.
Run kix doctor in the project directory to check kix.toml, the machine’s nix binary, allow-import-from-derivation, and whether the Nix store trusts your user:
❱ kix doctor Flake outputs when builder = "nix"
Section titled “Flake outputs when builder = "nix"”Setting builder = "nix" in kix.toml changes what kix.lib.mkFlake exports in your flake:
-
packages.<system>.cluster-<name>-activationis exported. This output creates a directory linkingactivation(theActivationresource manifest),kix-packages.json,kix-scorecard.json,kix-extra-images.json,kix-image-sources.json,kix-interface-*.json, andkix-activation-index.json. You can build it withnix buildand pass the result tokix diff --from. Projects using the defaultkixbuilder omit this output because they evaluate into~/.cache/kix/storewithout building derivations in/nix/store. -
packages.<system>.cluster-<name>andchecks.<system>.*support Helm charts. Under the defaultkixbuilder, Kix renders Helm charts outside Nix, so plainnix buildandnix flake checkcannot build clusters that use Helm charts. Underbuilder = "nix",mkFlakerenders Helm charts through Nix, sopackages.<system>.cluster-<name>and the cluster checks (schema-cluster-<name>,rules-cluster-<name>, andpi-wiring-cluster-<name>) work with plainnix buildandnix flake check. -
legacyPackages.<system>.kixClustersNix.<name>is used bykix. AlongsidelegacyPackages.<system>.kixClusters.<name>,mkFlakeexposeskixClustersNix.<name>evaluated with the Nix Helm route. Whenbuilder = "nix", thekixCLI evaluateskixClustersNix.<name>sokix build,kix plan, andkix deployshare the exact derivations thatnix buildproduces. -
legacyPackages.<system>.kixLibholds the library for the builder. It haskixandpackages, as a cluster function receives them, with Helm charts rendered by Nix underbuilder = "nix". A flake that mergesmkFlakeinto a larger flake uses it for its own checks.
Running nix directly on a nix project
Section titled “Running nix directly on a nix project”When you invoke kix, it automatically passes --extra-experimental-features "nix-command flakes pipe-operators" to nix. When you run nix build or nix flake check directly from your shell, enable those three experimental features on the command line or in nix.conf:
❱ nix build --extra-experimental-features "nix-command flakes pipe-operators" .#cluster-prod-activation In a project with a [versions] table, plain nix evaluates with inputs.kix. Evaluating a cluster assigned to another input such as kix-stable fails unless you run through kix or pass --override-input kix <locked-kix-stable-ref>.
Restricting systems for nix flake check
Section titled “Restricting systems for nix flake check”By default, kix.lib.mkFlake generates outputs for four platforms: x86_64-linux, aarch64-linux, aarch64-darwin, and x86_64-darwin. nix flake check checks only the machine’s own platform unless you pass --all-systems.
If a cluster uses Helm charts under builder = "nix", evaluating that cluster imports the output of a chart-rendering derivation (import-from-derivation). With --all-systems, Nix must build those derivations for every platform the flake lists. On a machine without remote builders for the other platforms, nix flake check --all-systems fails when it tries to build a chart derivation for another platform.
To avoid needing builders for platforms you do not use, pass systems to kix.lib.mkFlake with only the systems your team and CI build on:
1{2 inputs = {3 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";4 kix.url = "github:kix-run/kix/v0.10.0";5 kix.inputs.nixpkgs.follows = "nixpkgs";6 };7
8 outputs = inputs:9 inputs.kix.lib.mkFlake {10 inherit inputs;11 systems = [ "x86_64-linux" ];12 clusters.prod = ./clusters/prod.nix;13 };14}Validation and error messages
Section titled “Validation and error messages”| Condition | Error message |
|---|---|
| Invalid TOML syntax | <path> is not valid TOML: line <N>: <reason> |
Unknown key in kix.toml | <path> has an unknown setting `<key>` (Kix <version> supports: builder, library, upgrade, versions). Check the spelling, or upgrade Kix if the project needs a newer version |
library is neither "input" nor "self" | <path> sets library = <value>, which Kix does not know. Write library = "input" (the default: the flake input named kix holds the Kix library) or library = "self" (this flake provides the Kix library itself). |
library = "self" combined with [versions] | kix.toml cannot set `library = "self"` together with a `[versions]` table: a project whose own flake provides the Kix library has only one version of Kix. Remove `[versions]` (or remove `library = "self"`) from kix.toml. |
[versions] is not a table, or an entry is not a list of strings | Invalid `<key>` in kix.toml [versions]: map each input name to a list of cluster names, such as `kix = ["staging"]` and `kix-stable = ["prod"]`. |
Cluster listed under two inputs in [versions] | kix.toml [versions] lists cluster `<cluster>` under both `<first>` and `<second>`. Remove `<cluster>` from one of those lists so each cluster uses a single input. |
Cluster omitted from [versions] | Cluster `<cluster>` is not listed in kix.toml [versions]. Check the spelling (run `kix list clusters` to see defined clusters), or add `"<cluster>"` to one of the lists in kix.toml [versions] (`<input>`, ...). |
Cluster has the same name as an input (or kix) | kix.toml [versions] lists a cluster named `<name>`, which collides with the input `<name>` (`kix upgrade <name>` would be ambiguous). Rename input `<name>` in flake.nix and kix.toml [versions], then run `kix upgrade <new-input>` to lock it. (When <name> is kix, asks to rename the cluster instead.) |
[versions] names an input missing from flake.nix | kix.toml [versions] names input `<input>`, which is missing from flake.nix. Add `inputs.<input>.url = "github:kix-run/kix/v<version>";` to flake.nix, then run `kix upgrade <input>` to lock it. |
Input in flake.nix is not in flake.lock yet | Input `<input>` is defined in flake.nix and kix.toml [versions], but is not locked in flake.lock yet. Run `kix upgrade <input>` to lock it. |
Input in [versions] pins a newer release than kix | Input `<input>` pins Kix <newer>, which is newer than Kix <kix> on input `kix`. Input `kix` must pin the newest version in the project, and every command that builds or deploys a cluster (along with `kix upgrade`) stops until it does. Restore flake.nix and flake.lock from a commit where `<input>` pinned Kix <kix> or older. |
Plain nix evaluates a cluster whose input in [versions] is not kix | Cluster '<name>' is assigned to input `<input>` in kix.toml [versions], which pins a different Kix library than `inputs.kix`. The fix line adds: Run `kix check <name>` or `kix build <name>` so Kix selects `<input>` automatically, or pass `--override-input kix <locked-<input>-ref>` to `nix`. |
kix.toml sets kix | [K4476] <path> sets kix = "<value>", but Kix now takes this project's version from the Kix library tag in flake.lock. Delete the kix line from kix.toml, then run `kix upgrade --to <value>` to record the version this project uses now, then run `kix upgrade` to move to a newer version and review what changes. |
The version of Kix that flake.lock names is not installed, with KIX_AUTO_INSTALL=0 | This project uses Kix <version> (flake.lock), and Kix <version> is not installed. Automatic installs are off (KIX_AUTO_INSTALL=0). Run `kix self install <version>`. |
Unknown builder value | <path> sets builder = "<value>", which is not a known builder (Kix <version> supports: kix, nix, remote). Check the spelling, or upgrade Kix if the project needs a newer version |
builder without quotes, such as builder = 3 | <path> sets builder to a number. Write the builder's name in quotes, such as builder = "kix" (Kix <version> supports: kix, nix, remote) |
builder = "remote" | <path> sets builder = "remote", but remote builders are not supported yet. Set builder = "kix", or remove the setting |
builder = "nix" in kix.toml, but kix.toml is not tracked by Git | <path> is not tracked by Git, so Nix ignores it. Run `git add kix.toml` |
builder = "nix" in kix.toml, but the flake publishes no legacyPackages.<system>.kixConfig | <path> sets `builder = "nix"`, which this project's flake did not configure. The rest of the message says why: the Kix library in flake.lock is older than the builder setting (run kix upgrade --to <version> with the version of Kix you run), or flake.nix does not call kix.lib.mkFlake. |
KIX_STORE_ROOT set when builder = "nix" | KIX_STORE_ROOT is set, but it does not apply to this project. The project's builder is "nix", which uses the machine's Nix and its store. Unset KIX_STORE_ROOT |
nix not found on PATH when builder = "nix" | this project uses the `nix` builder (`builder = "nix"` in kix.toml), but `nix` is not on PATH. Install Nix 2.24 or later, or remove `builder = "nix"` from kix.toml |
Nix older than 2.24 on PATH | this project uses the `nix` builder (`builder = "nix"` in kix.toml), which requires Nix 2.24 or later, but `nix --version` reported <version>. Upgrade Nix, or remove `builder = "nix"` from kix.toml |
Lix on PATH | this project uses the `nix` builder (`builder = "nix"` in kix.toml), which does not support Lix (`nix --version` reported <version>). Install Nix 2.24 or later, or remove `builder = "nix"` from kix.toml |