host.mainModule omits content that needs an ancestor entity's context (host.parent)
With an entity kind above the host (den.schema.host.parent), host.mainModule doesn't contain host-class content that needs the ancestor's context. nixosConfigurations.<host> does. This is the remaining part of the #791 divergence, after #792.
Reproduction
den.schema.host.parent = "tier", a tier prod that delivers a marker to its hosts, and a host igloo under it. Comparing the mark-* sets in environment.etc:
| build | marks |
|---|---|
nixosConfigurations.igloo |
[ mark-base mark-tier-prod ] |
host.instantiate { modules = [ host.mainModule … ]; } |
[ mark-base ] |
The same on main and with #792.
The same shape applies with host.parent = "environment" (as in the Kubernetes case study), for:
- a host-scope include that destructures the ancestor,
{ environment, host, ... }: { includes = [ … ]; }; - the ancestor's
provides.to-users.
Cause
mainModule is the host's own resolve, rooted at the host with { host } as its context. It never walks the scopes above the host, so an include that needs environment never fires there and the ancestor's provides are never applied. nixosConfigurations is built from the host's part of the fleet-wide resolve, which walks flake → ancestor → host.
Impact
guides/from-flake-to-den.mdx has you add host.mainModule to an existing nixosSystem. With an ancestor kind, that config silently lacks the ancestor's content. reference/output.mdx states the limit since #792.
Direction
Have mainModule read the same per-host delivery projection as nixosConfigurations, checked by the same delivery oracle (nixosConfigurations marks against mainModule marks) for every ancestor delivery shape. The in-context and registry hasAspect work is moving to that projection too; the two should share it if they invoke it the same way.