Skip to content
kix /docs
Install the CLI

How-to guide Debug dependency wiring

Use aliases and default aliases

Make a package instance resolvable under a stable dependency name.

Use an alias when a package should satisfy a dependency name that differs from its instance name. Put a reusable default on the package, or set an alias on one instance when the mapping belongs to a particular cluster.

Add meta.defaultAliases when every instance of a package provides the same kind of dependency. A persistent-volume package can advertise itself as storage even when cluster authors choose names such as data or uploads:

packages/persistent-volume/default.nix
{
meta = {
version = "1.0.0";
defaultAliases = [ "storage" ];
};
build = { ... }: {
# Package resources.
};
}

A consumer declares the alias as its build argument:

packages/web/default.nix
build = { storage, ... }: {
dataMount = kix.mount.pvc storage { mountPath = "/data"; };
# Other package resources.
};

The cluster can now give the provider a task-specific instance name:

cluster.nix
instances.apps.data = {
package = packages.persistent-volume;
};

Kix indexes the instance under both data and storage.

Use the instance’s aliases field when the name applies only in this cluster:

cluster.nix
instances.apps.redis-primary = {
package = packages.valkey;
aliases = [ "cache" ];
};

A package with a required cache build argument can now resolve this instance.

A non-empty instance alias list replaces meta.defaultAliases for that instance. Include any package defaults you still need:

cluster.nix
aliases = [ "cache" "valkey" ];

Package roles remain available as aliases even when instance aliases replace the defaults.

Evaluate the cluster after adding an alias:

❱ kix check production

If more than one instance in the consumer’s namespace has the requested name or alias, Kix reports that the dependency matches multiple instances. Wire that consumer to the provider it should use:

cluster.nix
instances.apps.web = {
package = packages.web;
deps.cache = ref.apps.redis-primary;
};

This records the choice at the consumer, where the dependency is easiest to understand.

Aliases can also make two availablePackages entries answer one name. See Choose between catalog packages that answer one name.