Reference
The Reference section documents the options, functions, schemas, and policy rules that make up Kix. Each page is organized for quick lookup with field tables, default values, and compact examples.
Reference sections
Section titled “Reference sections”Cluster and instance configuration
Section titled “Cluster and instance configuration”| Page | Covers |
|---|---|
kix.toml | Project configuration beside flake.nix that chooses whether Kix evaluates with the Kix runtime (builder = "kix") or the machine’s Nix (builder = "nix"). |
| Cluster configuration | How to configure cluster-wide settings such as availability targets, namespaces, network policies, and scorecard enforcement. |
| Instances and composition | How to declare package instances in a cluster, wire dependencies across namespaces, and stamp environments across teams. |
| Flavors and capabilities | Built-in provider profiles (kix.flavors.*) that pre-configure cloud capabilities, storage classes, and platform services. |
Package authoring and helpers
Section titled “Package authoring and helpers”| Page | Covers |
|---|---|
| Package anatomy | The structure of a Kix package file, how it declares typed options, and how it builds Kubernetes resources. |
Resources and out | How scope builders construct Kubernetes resources and expose .out fields that track dependencies automatically. |
| Composition helpers | Shorthand kix.* functions for environment variables, volume mounts, Services, ingress routes, monitoring, and health checks. |
| Secrets, CRDs, and RBAC | Specialized builders that validate Secret keys, CustomResourceDefinitions, and RBAC permissions at build time. |
| Helm and imports | How to wrap upstream Helm charts as Kix packages and model pre-existing cluster services with kix.mkImport. |
Policy, validation, and runtime records
Section titled “Policy, validation, and runtime records”| Page | Covers |
|---|---|
| Dependency contracts | Shared kix.contracts.* schemas, credential rules (out.credentials), and kix.mkImport shapes for databases, Redis, mail (smtp), single sign-on (oidc), Gateways, and OpenTelemetry. |
| Scorecard and rules | How build-time scorecard rules work, how to customize severities, and the full catalog of built-in checks. |
| Validation checks | The 24 always-on cross-resource checks that verify selectors, ports, volumes, and CRD ordering on every build. |
| Annotations, CRDs, and receipts | Bookkeeping kix.run/* annotations, in-cluster Activation and PackageInstance records, and deploy receipts. |
I want to…
Section titled “I want to…”| Goal | Where to look |
|---|---|
| Choose whether a project uses the Kix runtime or the machine’s Nix installation | kix.toml |
| Understand how dependencies control deploy order and network policies | The dependency graph |
| Write a package with a Deployment and Service | Package anatomy, Resources and out, and Composition helpers |
| Add typed configuration options to a package | Add typed package options and Package anatomy |
| Expose a Service with an Ingress or Gateway API HTTPRoute | Expose a service with Ingress, Expose a service with Gateway API, and Composition helpers |
| Wire a package to a specific database, cache, or storage instance | Instances and composition and Wire cross-namespace dependencies explicitly |
Connect an external database, Redis cache, mail server (smtp), or single sign-on provider (oidc) | Connect external databases, caches, mail, and single sign-on, Import an existing service with kix.mkImport, and Dependency contracts |
| Manage Secrets, CRDs, or RBAC permissions in a package | Secrets, CRDs, and RBAC |
| Wrap an upstream Helm chart as a Kix package | Helm and imports and Helm integration |
| Set cluster availability levels and derive pod spread and PDBs | Cluster configuration and Availability levels |
| Configure or override scorecard rules | Scorecard and rules and Cluster configuration |
| Customize an instance’s resources from the cluster without editing the package | Instances and composition and Patch package output with overlays |
| Stamp the same application stack across multiple environments | Instances and composition |
Top Nix DSL idioms
Section titled “Top Nix DSL idioms”Common patterns used across Kix packages and cluster definitions:
1# Reference a resource name while tracking the dependency:2self.service.out.name3
4# Reference a Service's in-cluster FQDN or URL:5self.service.out.fqdn6self.service.out.url { scheme = "http"; port = 8080; }7
8# Reference a workload's pod selector while tracking the dependency:9self.deployment.out.selector10
11# Read a workload's pod selector without creating a dependency cycle:12self.deployment.rawSelector13
14# Build a workload with volume mounts using the pipe operator:15{ name = "web"; spec = { ... }; }16 |> kix.withMounts [ self.dataMount ]17 |> scope.mkDeployment18
19# Derive a Service from a workload's selector and container ports:20self.deployment21 |> kix.service.fromWorkload { name = "web"; }22 |> scope.mkResource23
24# Expose a Service via Ingress or Gateway API HTTPRoute:25(kix.expose { service = "service"; })26
27# Create a ServiceMonitor and optional alert rules when Prometheus is present:28(kix.monitor { service = "service"; port = "metrics"; })29
30# Run a post-deploy health check Job against service outputs:31(kix.healthCheck {32 script = builtins.readFile ./health-check.py;33 env = { self, ... }: { TARGET_URL = self.service.out.url { }; };34})35
36# Reference a key from a Kix-managed Secret:37self.credentials.out.keyRef "password"38
39# Reference a key from an externally managed Secret:40(scope.mkSecretRef {41 name = "external-db-creds";42 keys = [ "username" "password" ];43}).out.keyRef "password"44
45# Read a container image from a committed pin file and render repo:tag@digest:46# (in cluster config) config.image = pins.get "web";47# (in package build) image = kix.image.ref config.image;48
49# Convert an attribute set of environment variables to a Kubernetes env list, dropping nulls:50kix.mkEnvVars {51 LOG_LEVEL = config.logLevel;52 OPTIONAL_FLAG = config.optionalFlag or null;53 DB_PASSWORD = database.out.credentials.out.keyRef "password";54}55
56# Gate an optional resource on a boolean condition:57scope.mkOptional config.metrics.enabled (_: scope.mkResource { ... })58
59# Write an intentional empty map (such as emptyDir) that must not be stripped:60emptyDir = { };61
62# Prevent a constructor-built map from collapsing when all optional fields are null:63kix.keep {64 medium = config.medium;65 sizeLimit = config.sizeLimit;66}