den icon indicating copy to clipboard operation
den copied to clipboard

A host aspect child named after a user (`den.aspects.<host>.<user>`) reaches every user on the host

Open sini opened this issue 1 week ago • 0 comments

A host aspect's child named after a user, such as den.aspects.igloo.tux, is meant to configure that user on that host. Instead it reaches every user on the host.

den.hosts.x86_64-linux.igloo.users = { tux = { }; pingu = { }; };
den.aspects.igloo.tux.homeManager.home.sessionVariables.PERHOST = "tux-on-igloo";

On main (74d921ba), pingu's home on igloo gets PERHOST = "tux-on-igloo" as well as tux's. A { user, ... }: function under den.aspects.igloo.tux runs once for every user on igloo, not just for tux. User-class content leaks the same way, and two users' keys can conflict.

The cause is in modules/policies/core.nix. host-to-users runs at host scope and returns include aspect.${user.name} there, so the child is included in the host's scope, which every user on the host inherits. The file's own comments say the child is "included in the target entity scope" and "in the user scope", and the docs already flag the current behaviour as a probable defect (Where Does My Config Land?, the den.aspects.igloo.tux caution).

The fix is to make the child part of that user's own aspect on that host, so it reaches that user only, everywhere the user resolves (home environments included), and runs once. Keys forwarded through provides keep going through their deliveries.

This changes output for any config that relied on the leak to give every user the same content. That content belongs in den.aspects.<host>.provides.to-users or den.schema.user.includes. Until the fix lands, den.aspects.<host>.provides.<user> and den.aspects."<user>@<host>" already target one user.

sini avatar Nov 24 '26 07:11 sini