Migrating from den.ctx
den.ctx is deprecated. A compatibility shim forwards den.ctx definitions to
den.schema.<kind>.includes with deprecation warnings, so existing configs still
evaluate — but you should migrate to remove the warnings and use the current API.
What changed
Section titled “What changed”Old (den.ctx) | New | Notes |
|---|---|---|
den.ctx.<name> = { ... } | den.aspects.<name> = { ... } | Aspect definitions live here now. |
den.ctx.<name>.includes | den.schema.<kind>.includes | Explicit activation on entity kinds. |
den.ctx.<name>.provides.<p> | den.schema.<kind>.includes or policy | Cross-entity inclusion via schema or policy. |
den.ctx.<name>.into | den.policies | Entity topology via first-class policies. |
den.ctx.<name>.meta.adapter | (removed) | Pipeline handles class routing automatically. |
den.lib.ctxApply | (removed) | No shim — see step 5 below. |
Compatibility shim
Section titled “Compatibility shim”The shim (modules/compat/ctx-shim.nix) is always imported. At evaluation time
it forwards den.ctx.<name> values into den.schema.<name>.includes with
lib.warn deprecation messages. The shim handles flat entries only — den.ctx
never supported nested namespaces.
The shim will be removed after the first stable release.
Migration steps
Section titled “Migration steps”-
Move aspect definitions to
den.aspectsAspect content that was defined inline in
den.ctxmoves to the aspects registry:# Beforeden.ctx.host = {provides.host = { host }: den.aspects.${host.aspect};};# Afterden.aspects.my-aspect = { host }: {nixos.services.foo.enable = true;}; -
Activate aspects via
den.schema.*.includesInstead of
den.ctx.<name>.includes, add aspects to the relevant entity kind’s includes list:# Beforeden.ctx.host.includes = [ den.provides.hostname ];# Afterden.schema.host.includes = [ den.provides.hostname ]; -
Move
intotransitions toden.policiesIf you used
den.ctx.<name>.intoto fan out from one entity kind to another, declare an explicit policy:# Beforeden.ctx.host.into = { host }:map (user: { inherit host user; }) (lib.attrValues host.users);# Afterden.policies.host-to-users = { host, ... }:map (user: policy.resolve.to "user" { inherit host user; })(lib.attrValues host.users);See Policies for the full policy model.
-
Remove
meta.adapterThe
meta.adapteroption no longer exists. The pipeline determines which class keys apply to each output automatically. Delete anymeta.adapterassignments. -
Replace
ctxApplycallsden.lib.ctxApplyhas no compatibility shim. If you called it directly, replace it with aspect definitions activated viaden.schema.*.includes. -
Verify
Rebuild your system and confirm no deprecation warnings remain:
Terminal window nixos-rebuild build --flake . 2>&1 | grep -i 'deprecated'
Further reading
Section titled “Further reading”- Policies — declaring how entity kinds relate
- Entities & Schema — entity declarations and schema
- den.ctx compat shim — what the shim does