resolveImports drops policy.spawn requests, so host-aspects is silently inert on a static resolve
den.lib.aspects.resolveImports (fxResolveImports, nix/lib/aspects/fx/resolve.nix) never materializes deferred node spawns (den.lib.policy.spawn). So den.batteries.host-aspects silently does nothing when an entity is resolved through it.
What happens
host-aspects' policy (modules/aspects/batteries/host-aspects.nix) emits policy.spawn { classes = user.classes; }. fxResolve materializes these after the walk (homeNodeSpawns, folded into mkDrained). fxResolveImports documents that it has "no drain / phase4 / assembleSubtree", and result.state.scopedSpawns is never read on that path. The spawn requests are collected and then dropped, with no warning.
Even if it drained, the spawn would be skipped for a root resolve. homeNodeSpawns needs scopeParent.${scopeId} with an entity record, and projects parentRecord.aspect. A user resolved as the root of resolveImports (den.lib.resolveEntity "user" { inherit host user; }) has no parent scope, so the host's aspect has nothing to project from.
The result is a homeManager evaluation that silently lacks:
- every host aspect's
homeManagercontent; - per-user quirks contributed through the projected host aspects;
- fleet-collected pipe values: a pipe consumer in a projected aspect reads
[].
Reproduction
Any static resolution of a user that includes den.batteries.host-aspects:
den.lib.aspects.resolveImports "homeManager"
(den.lib.resolveEntity "user" { inherit host user; })
Compare that with the same user's home-manager config from a normal host resolve. Host-aspect homeManager keys are absent from the first.
Where this bit us
We deliver microvm guests as isolated child entities. Isolation drops the standard home-manager battery's forward for a user under the guest, so the guest delivery bridges each user's home-manager with exactly the call above. With host-aspects on the user, the guest's users got none of the host's homeManager content. Explicitly including the host aspect in the root resolve restores the content but not the fleet pipes: a syncthing peer set collected across hosts came out empty.
Possible directions
- Drain spawns in
fxResolveImports. Run the samehomeNodeSpawnsmaterialization thatfxResolveruns, at least when spawns were requested. - Let a static resolve take a parent scope. For example, a
parentbinding that seedsscopeParent/scopeEntityKind, so a spawn requested by a root-resolved user can find the host record it projects from. - At minimum, fail loudly. Throw or warn when
scopedSpawnsis non-empty on a path that cannot materialize it, so the content is never dropped silently.
Observed at den 0f7675b0.
A second mechanism blocks the obvious alternative, which is to skip the static resolve and let the standard home-manager battery deliver a guest's users.
Our setup: a guest is an isolated child entity. Its nixos content is delivered by a simple route { fromClass = "nixos"; collectSubtree = true; appendToParent = true; reinstantiate = true; } registered in the guest scope. host-to-users and the home-manager battery both fire inside the guest scope. But the battery's per-user output is a complex forward (its intoPath is a function, so needsAdapter), and materialize-unified.nix documents:
Simple routes read the FROZEN phase-1 perScope (seed.perScope), NOT the evolving acc
So the delivery route collects the guest subtree from the snapshot taken before the forward wrote home-manager.users.<u>. Measured: with our static bridge disabled, the delivered guest's home-manager.users is {}, although a home-manager user is resolved under the guest.
aliasedPerScope already makes class-alias output visible to other simple routes. The general form would let a collectSubtree route see complex-forward output from its subtree, ordered after those producers (topoSortEdges already places synthesize edges after the producers of their fromClass). A complex forward with appendToParent/collectSubtree would also work.
With both pieces (this, and spawns draining with a parent scope), a guest's users would get host-aspects projections and fleet pipe values exactly as a host's users do, and consumers could drop their static bridge.