Reference / CLI
Eval cache behavior
These docs describe Kix's main branch, which can include changes not yet released. Read the docs for the latest release.
Kix keeps the results of cluster evaluations in local files so that repeated commands against an unchanged project skip evaluation. A cached result is reused only when every file the evaluation reads is unchanged.
This page is hand-maintained. Check cli/kix-core/src/eval/cache.rs,
cli/kix-core/src/eval/evaluator.rs, and cli/kix-core/src/eval/store.rs when in doubt.
Location
Section titled “Location”| Path | Content |
|---|---|
<cache dir>/kix/eval-cache | Evaluation results, one file each |
<cache dir>/kix/store | Kix’s local store for the default kix builder (flake inputs, rendered Helm charts, and evaluated manifests), or $KIX_STORE_ROOT when set; projects with builder = "nix" in kix.toml use /nix/store instead |
<cache dir>/kix/activations/<cluster> | Symlinks and paths for each cluster’s last local activation |
<cache dir> is $XDG_CACHE_HOME when set, or ~/.cache on both Linux and
macOS. Deleting eval-cache is safe. The next command re-creates it and
evaluates the cluster again.
Kix keeps one result for each project and each thing it evaluates, such as a cluster. A new result replaces the old one, so the cache does not grow as you edit. Switching back to a branch you used before evaluates its clusters again.
What is cached
Section titled “What is cached”| Entry | Used by |
|---|---|
| A cluster’s evaluation: rendered manifests and the scorecard report | build, check, graph, list resources, list images, compliance audit |
| The flake’s cluster names | list clusters, and the “did you mean” list when a cluster is not found |
| Available packages, and a cluster’s instances | list packages |
Commands that evaluate the cluster’s activation index directly, such as
deploy, plan, diff, bundle, export, logs, and port-forward, do not read
the eval cache. They evaluate the cluster each time. The store
(<cache dir>/kix/store under the default kix builder, or /nix/store
under builder = "nix") keeps the project’s inputs and rendered Helm charts,
so these are not fetched or rendered again.
Cache key
Section titled “Cache key”Each entry’s key is a BLAKE3 hash of:
- the canonical path of the flake directory;
- the fingerprint of the project’s source, described below;
- the name of what was evaluated, such as the cluster name;
- the Kix version, because only an evaluation checks that Kix can build the project’s Kix library;
- the project’s builder (
kixornix, fromkix.toml); - the store location (the local store root path for
kix, or the system store marker fornix).
Kix does not decide which files an evaluation reads. It asks the Nix in the
Kix runtime (or the machine’s Nix under the nix builder) for the
fingerprint of the flake, with nix flake metadata. The fingerprint is a
hash of the project’s source and its flake.lock. What counts as the source
depends on where the flake directory is:
| Flake directory | Source |
|---|---|
| Inside a Git repository | Every file Git tracks in the repository, with its uncommitted changes. A file Git does not track is not part of the project until you git add it, and an evaluation cannot read it. |
| A plain folder | Every file in the folder. |
An input that flake.nix names by a relative path, such as
kix.url = "path:../kix", is read from the same repository, so the
fingerprint covers it. Every other input is pinned in flake.lock, which the
fingerprint also covers.
Reading the fingerprint takes about a tenth of a second, and Kix reads it once for each command that uses the cache.
What invalidates an entry
Section titled “What invalidates an entry”- Adding, removing, or editing a file that is part of the project’s source, whatever its extension. In a Git repository this includes a tracked file outside the flake directory.
- Committing, or switching to another commit.
- Any change to
flake.lock, such askix upgrade. - Running another version of Kix.
- Changing
builderinkix.tomlor changingKIX_STORE_ROOT. - Running from a different flake directory.
Kix does not use the cache when you pass --override-input, because the
fingerprint describes the inputs in flake.lock and an override replaces one
of them. For the same reason, clusters assigned to an input other than kix in
[versions] do not use the
cache: Kix overrides kix with that cluster’s input during evaluation, so those
clusters evaluate from source each time. Moving a cluster to kix in a tracked
kix.toml also invalidates any earlier cache entry because both the source
fingerprint and the running Kix version change.
Kix evaluates every time, and stores nothing, when Nix gives the project no fingerprint. This happens in a Git repository that has submodules and uncommitted changes.
--no-cache evaluates from source and neither reads nor writes the cache.
You do not need it after editing a file.
A cache entry that cannot be parsed is discarded and the evaluation runs again. A failure to write the cache is logged and does not fail the command.
Remote flake references
Section titled “Remote flake references”The commands that use this cache need a local directory. They fail when
--flake names a remote reference such as github:org/repo, with or without
--no-cache. Clone the repository and pass its local path.