Skip to content
kix /docs
Install the CLI

Reference Package schema

build

The package function or functions that produce named resources and a root.

build is the required package entry that constructs resources. It may be one function or a list of functions:

build = { self, config, scope, database, ... }: {
deployment = scope.mkDeployment {
name = scope.instanceName;
spec.replicas = config.replicas;
};
root = self.deployment;
};
ArgumentValue
selfLazy fixed point containing the parts returned by every build entry.
configEvaluated values declared by the package’s options.
clusterConfigFull evaluated cluster configuration.
scopeConstructors and instance context for the current namespace.
libThe nixpkgs library.
kixKix composition helpers.
depsAll resolved package dependencies in one attribute set.
availabilityResolved availability level for this instance.

Any other named argument is a dependency request. A required argument must resolve to an instance, import, direct deps value, or catalog entry. An argument with a default is optional:

build = { self, scope, database, metrics ? null, ... }: {
# ...
};

Usually a package names dependencies as individual arguments. deps is useful to generic build entries that need to inspect all resolved dependencies.

The function returns an attribute set of named parts. Resource values may be nested, including in the reserved secrets and crds folders. The result must contain root, pointing to a resource also assigned to a named part.

Use self.<part> when one part reads another. Values in out carry Nix string context, so fields such as self.service.out.name record the resource dependency as well as producing the Kubernetes name. Use a resource’s requires list when no rendered field naturally carries the dependency.

A list lets reusable entries contribute parts and declare their own dependencies:

build = [
({ self, scope, ... }: {
deployment = scope.mkDeployment { /* ... */ };
service = kix.service.fromWorkload { name = scope.instanceName; } self.deployment
|> scope.mkResource;
root = self.service;
})
(kix.expose { service = "service"; })
(kix.monitor { service = "service"; port = "metrics"; })
];

Kix imports path entries, discovers dependencies from every function’s arguments, and merges their returned attribute sets. Two entries that return the same part name are an evaluation error that names the part. Rename one of them, or use partsOverlays to replace a part on purpose. A set of parts keyed by user input belongs under a folder part, such as proxyClasses.<name>, so that its keys cannot collide with other parts.

Cluster-wide and instance partsOverlays run after the build entries.