Skip to content

fix: keep same-username homes on different hosts distinct - #641

Merged
sini merged 2 commits into
denful:mainfrom
nolith:fix-samename-crosshost-homes
Jul 30, 2026
Merged

fix: keep same-username homes on different hosts distinct#641
sini merged 2 commits into
denful:mainfrom
nolith:fix-samename-crosshost-homes

Conversation

@nolith

@nolith nolith commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Hello, I'm migrating my nix config to den and found that when home-manager and the OS are managed as separate outputs, a few strange things will happen.

Two standalone home configs that share a username but target different hosts (user@hostA, user@hostB) were stepping on each other: each flake output ended up with the other's configuration.

The cause was that a home's name is deliberately force-set to the bare username, and den used that name as an entity's identity in two separate places: the id_hash used by the edge layer and the scope string built by mkScopeId in the resolution pipeline. So both homes looked identical and collapsed onto one another.

This PR gives entities a distinct internal identity (__scopeName, the full registry key like user@hostA) and teaches both keying layers to use it, so same-username homes on different hosts stay cleanly separated while their user-facing name and description are untouched.

It ships as two commits (one per keying layer, since both are needed) plus regression tests covering the id_hash and scope paths.

nolith added 2 commits July 29, 2026 18:56
Two standalone homes sharing a username but bound to different hosts
had identical id_hash values, so id_hash-keyed entity resolution could
not distinguish them.

Use the registry key and system as the explicit home identity. This
keeps identity independent of user-overridable presentation metadata
while preserving uniqueness for the same registry key across systems.

AI-assisted: GitLab Duo Agentic Chat (GPT-5.6 Sol)
Two standalone homes sharing a username but bound to different hosts
(user@hostA, user@hostB) collapsed onto a single pipeline scope:
mkScopeId rendered an entity value as v.name, and a home's name is
force-set to the bare user name, so both rendered home=user. Their
collected class content merged and each flake output yielded the other's
configuration.

Entities now expose __scopeName, their registry key, which is unique per
kind per system. mkScopeId prefers it and falls back to name, so only
kinds that rewrite name behave differently, and scope ids stay readable
in traces and error messages.

This is a separate keying layer from the parent commit's id_hash fix,
and neither alone is sufficient: id_hash keys the edge layer, where
entity scopes are named "<kind>:<id_hash>" and same-name siblings
collapse by design, while mkScopeId keys the resolution pipeline and
never read id_hash. The added regression suite therefore needs both
commits.

AI-assisted: Claude Code (opus-5)
@nolith
nolith requested review from sini and vic as code owners July 29, 2026 17:03
@vic vic added the allow-ci allow all CI integration tests label Jul 29, 2026
@vic

vic commented Jul 29, 2026

Copy link
Copy Markdown
Member

at first glance, changes look good to me, however I'd like to know if @sini is ok with them, my only question is if we do have to keep the name = mkForce (is forcing it -as we currently do- actually needed?, would removing that mkForce avoid we introducing a new attr?

@sini

sini commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

A good question, @vic. Not one I think we need to block acceptance on. Given my intention is to replace this system soon I'm inclined to simply accept this contribution as-is.

@sini
sini enabled auto-merge (squash) July 30, 2026 01:31
@sini
sini merged commit 7f11ba1 into denful:main Jul 30, 2026
39 of 76 checks passed
@nolith
nolith deleted the fix-samename-crosshost-homes branch July 30, 2026 04:49
@nolith

nolith commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Thank you very much for the quick review

worldofgeese added a commit to worldofgeese/den that referenced this pull request Aug 1, 2026
Picks up denful/den#641 (same-username homes on different hosts stay
distinct) and #643 (four silent-drop defects in forward classes and
standalone homes). Only #643's fix for {user, ...} being dropped on
standalone homes touches us -- den.homes.x86_64-linux.worldofgeese is our
only standalone home -- and worldofgeese evaluates identically before and
after (username, homeDirectory, 85 packages, stateVersion). just check
passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-ci allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants