# kix.toml

`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](#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](#the-version-of-kix) explains.

:::note[Helpful background]
- [Install and run Kix](/docs/how-to/start-and-inspect/install-and-run-the-kix-cli/): see how the release archive ships the Kix runtime and how to verify your setup with `kix doctor`.
- [Use `mkFlake` in a consuming repo](/docs/how-to/start-and-inspect/use-mkflake-in-a-consuming-repo/): set up `flake.nix` in your own repository so `kix.lib.mkFlake` reads `kix.toml` and wires cluster outputs.
- [Helm integration](/docs/explanation/helm-integration/): understand how each builder fetches and renders Helm charts.
- [Nix command reference (nix.dev)](https://nix.dev/manual/nix/latest/command-ref/new-cli/nix): reference for the `nix` CLI, `nix.conf` settings, binary caches, and remote builders used when `builder = "nix"`.
:::

## Location and format

Kix looks for `kix.toml` in the directory named by [`--flake`](/docs/reference/cli/global-flags/) (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"`).

```toml
# kix.toml
builder = "nix"
```

The file and its settings are optional. An absent `kix.toml` or an empty `kix.toml` is equivalent to:

```toml
builder = "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-library-setting), the [`[upgrade]` table](#the-upgrade-table), and the [`[versions]` table](#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

`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](#the-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](/docs/how-to/start-and-inspect/install-and-run-the-kix-cli/#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>`](/docs/reference/cli/upgrade/) 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](/docs/how-to/start-and-inspect/upgrade-a-project-to-a-new-kix/#upgrade-a-project-from-kix-09) gives each step.

## 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 named `kix` (plus any additional inputs listed in [`[versions]`](#the-versions-table)), and each input's release tag in `flake.lock` is 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.

```toml
# kix.toml
library = "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](/docs/how-to/start-and-inspect/install-and-run-the-kix-cli/#work-on-the-kix-library-itself), 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

| 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)

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"`

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 build` or `nix flake check` on clusters that include Helm charts.
- The `packages.<system>.cluster-<name>-activation` flake output for scripts or CI pipelines that build activations directly with `nix 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)

`builder = "remote"` is reserved for a build service that builds the project on another machine. This version of Kix refuses it:

```text
<path>/kix.toml sets builder = "remote", but remote builders are not supported yet. Set builder = "kix", or remove the setting
```

## The `[upgrade]` table

The `[upgrade]` table configures how [`kix upgrade`](/docs/reference/cli/upgrade/) selects target releases when upgrading an input:

```toml
[upgrade]
min-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

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`.

```nix
# flake.nix (version numbers are examples)
{
  inputs.kix.url        = "github:kix-run/kix/v0.14.2";
  inputs.kix-stable.url = "github:kix-run/kix/v0.12.3";   # held back

  outputs = inputs: inputs.kix.lib.mkFlake {
    inherit inputs;
    clusters.staging = ./clusters/staging.nix;
    clusters.prod    = ./clusters/prod.nix;
  };
}
```

```toml
# kix.toml
[versions]
kix        = ["staging"]
kix-stable = ["prod"]
```

### Rules

- **List every cluster.** Once `[versions]` exists, every cluster in `flake.nix` must appear in the table.
- **`kix` pins the newest release.** No other input in `[versions]` may pin a newer release than `kix`. 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 named `kix`.
- **Every key is a locked input.** Each key in `[versions]` must be declared in `flake.nix` and locked in `flake.lock`. Lock a new input with [`kix upgrade <input>`](/docs/reference/cli/upgrade/).
- **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 reject `versions` as an unknown setting in `kix.toml`.

### 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 `kix` validates all `kix.toml` settings and `mkFlake` arguments, failing on unknown keys or arguments.
- Older Kix versions in `[versions]` ignore unknown `kix.toml` keys and unknown `mkFlake` arguments, while still rejecting invalid values for settings they recognize.

:::tip[Use it in a task]
See [Keep clusters on different versions of Kix](/docs/how-to/start-and-inspect/hold-clusters-on-different-kix-versions/) for step-by-step instructions to upgrade staging before production.
:::

## 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:

```text
./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:

<Command commands={[
  'git add kix.toml',
]} />

Two other conditions must hold for the CLI and the flake library to agree:

1. `flake.nix` must pass `inputs` (which includes `self`) to `kix.lib.mkFlake { inherit inputs; ... }`, so `mkFlake` can locate `${inputs.self}/kix.toml`.
2. The `kix` flake input locked in `flake.lock` must be new enough to expose `kixConfig`. If the locked library predates `kix.toml` support, `kix` prompts you to run [`kix upgrade --to <version>`](/docs/reference/cli/upgrade/) with its own version.

## 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)` in `nix --version` and is refused because this builder relies on upstream Nix's flake and pipe-operator behavior.
- **`allow-import-from-derivation` enabled (`true`).** This is the default in Nix. When `builder = "nix"`, [`scope.helm.importChart` and `kix.helmChart`](/docs/reference/helm-and-imports/) build a derivation that runs `helm template` and import the rendered JSON during evaluation (Import From Derivation, or IFD). If `allow-import-from-derivation` is set to `false` in `nix.conf`, evaluating a cluster that uses Helm charts fails.
- **No `trusted-users` requirement.** The `nix` builder uses ordinary fixed-output derivations for chart downloads and standard derivations for chart rendering. Your user account does **not** need to be listed in `trusted-users` on the Nix daemon.
- **`KIX_STORE_ROOT` must be unset.** `KIX_STORE_ROOT` only redirects the local store of the `kix` builder. If `KIX_STORE_ROOT` is set in the environment for a project with `builder = "nix"`, `kix` stops and asks you to unset `KIX_STORE_ROOT`.

Run [`kix doctor`](/docs/reference/cli/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:

<Command commands={[
  'kix doctor',
]} />

:::tip[Common tasks]
- [Install and run Kix](/docs/how-to/start-and-inspect/install-and-run-the-kix-cli/): verify your Kix installation and inspect `kix doctor` output.
- [`kix doctor` CLI reference](/docs/reference/cli/doctor/): see every check `kix doctor` runs for `"kix"` and `"nix"` projects.
:::

## Flake outputs when `builder = "nix"`

Setting `builder = "nix"` in `kix.toml` changes what `kix.lib.mkFlake` exports in your flake:

- **`packages.<system>.cluster-<name>-activation` is exported.** This output creates a directory linking `activation` (the `Activation` resource manifest), `kix-packages.json`, `kix-scorecard.json`, `kix-extra-images.json`, `kix-image-sources.json`, `kix-interface-*.json`, and `kix-activation-index.json`. You can build it with `nix build` and pass the result to [`kix diff --from`](/docs/reference/cli/diff/). Projects using the default `kix` builder omit this output because they evaluate into `~/.cache/kix/store` without building derivations in `/nix/store`.
- **`packages.<system>.cluster-<name>` and `checks.<system>.*` support Helm charts.** Under the default `kix` builder, Kix renders Helm charts outside Nix, so plain `nix build` and `nix flake check` cannot build clusters that use Helm charts. Under `builder = "nix"`, `mkFlake` renders Helm charts through Nix, so `packages.<system>.cluster-<name>` and the cluster checks (`schema-cluster-<name>`, `rules-cluster-<name>`, and `pi-wiring-cluster-<name>`) work with plain `nix build` and `nix flake check`.
- **`legacyPackages.<system>.kixClustersNix.<name>` is used by `kix`.** Alongside `legacyPackages.<system>.kixClusters.<name>`, `mkFlake` exposes `kixClustersNix.<name>` evaluated with the Nix Helm route. When `builder = "nix"`, the `kix` CLI evaluates `kixClustersNix.<name>` so `kix build`, `kix plan`, and `kix deploy` share the exact derivations that `nix build` produces.

- **`legacyPackages.<system>.kixLib` holds the library for the builder.** It has `kix` and `packages`, as a cluster function receives them, with Helm charts rendered by Nix under `builder = "nix"`. A flake that [merges `mkFlake` into a larger flake](/docs/how-to/start-and-inspect/use-mkflake-in-a-consuming-repo/#use-mkflake-inside-a-larger-flake) uses it for its own checks.

### 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`:

<Command commands={[
  'nix build --extra-experimental-features "nix-command flakes pipe-operators" .#cluster-prod-activation',
]} />

In a project with a [`[versions]` table](#the-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`

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:

```nix
# flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    kix.url = "github:kix-run/kix/v0.10.0";
    kix.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = inputs:
    inputs.kix.lib.mkFlake {
      inherit inputs;
      systems = [ "x86_64-linux" ];
      clusters.prod = ./clusters/prod.nix;
    };
}
```

## 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 `` |