Skip to content

fix: user-scope detection for home-env batteries and diagram null guard - #533

Merged
sini merged 1 commit into
denful:mainfrom
sini:fix/hjem-battery-missing-input
May 13, 2026
Merged

sini merged 1 commit into
denful:mainfrom
sini:fix/hjem-battery-missing-input

Conversation

@sini

@sini sini commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • User-scope detection for home-env batteries: The host-scope battery policy relied on host.users to detect class membership, which fails when users come from external registries resolved via policies (e.g. fleet-demo). Added userDetect — a user-scope policy on den.schema.user.includes that fires at { host, user } context regardless of how the user was resolved. Applied to all three batteries: homeManager, hjem, maid.

  • Guard hjem/maid against missing inputs: hjem.nix and maid.nix unconditionally accessed inputs.hjem/inputs.nix-maid in getModule, crashing any flake without those inputs. Now throws an actionable error message instead.

  • Fix diagram null coercion: entityInstance is explicitly set to null in graph entries, but text.nix used or "" which only catches missing attrs. Changed to proper null-aware checks matching the existing instOf pattern from graph.nix.

Test plan

  • 786/786 CI tests pass
  • nix eval --override-input den . ./templates/fleet-demo#den evaluates cleanly
  • nix flake check --override-input den . ./templates/minimal passes

@sini
sini requested a review from vic as a code owner May 13, 2026 21:19
@github-actions github-actions Bot added the allow-ci allow all CI integration tests label May 13, 2026
@sini
sini force-pushed the fix/hjem-battery-missing-input branch from e43e754 to 99f02e7 Compare May 13, 2026 21:23
@theutz

theutz commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Fixed my issue!

Comment thread nix/lib/diag/text.nix Resolved
Comment thread nix/lib/diag/text.nix Resolved
Comment thread nix/lib/diag/text.nix Resolved
@sini
sini force-pushed the fix/hjem-battery-missing-input branch from 99f02e7 to fc3057a Compare May 13, 2026 21:41
Home-env batteries (homeManager, hjem, maid) relied on host.users to
detect class membership, which fails when users come from external
registries resolved via policies (e.g. fleet-demo).  Add userDetect —
a user-scope policy that fires at { host, user } context regardless
of how the user was resolved — and wire it into den.schema.user.includes
for all three batteries.

Also guard hjem/maid getModule against missing flake inputs (throw with
actionable message instead of cryptic attr-missing), and fix null
entityInstance coercion in diag/text.nix that crashed diagram rendering.
@sini
sini force-pushed the fix/hjem-battery-missing-input branch from fc3057a to e8eb4c3 Compare May 13, 2026 21:41
@sini
sini enabled auto-merge (squash) May 13, 2026 21:42
@sini
sini merged commit ea25150 into denful:main May 13, 2026
15 checks passed
charlesfire pushed a commit to charlesfire/den that referenced this pull request May 16, 2026
…rd (denful#533)

## Summary

- **User-scope detection for home-env batteries**: The host-scope
battery policy relied on `host.users` to detect class membership, which
fails when users come from external registries resolved via policies
(e.g. fleet-demo). Added `userDetect` — a user-scope policy on
`den.schema.user.includes` that fires at `{ host, user }` context
regardless of how the user was resolved. Applied to all three batteries:
homeManager, hjem, maid.

- **Guard hjem/maid against missing inputs**: `hjem.nix` and `maid.nix`
unconditionally accessed `inputs.hjem`/`inputs.nix-maid` in `getModule`,
crashing any flake without those inputs. Now throws an actionable error
message instead.

- **Fix diagram null coercion**: `entityInstance` is explicitly set to
`null` in graph entries, but `text.nix` used `or ""` which only catches
missing attrs. Changed to proper null-aware checks matching the existing
`instOf` pattern from `graph.nix`.

## Test plan

- [x] 786/786 CI tests pass
- [x] `nix eval --override-input den . ./templates/fleet-demo#den`
evaluates cleanly
- [x] `nix flake check --override-input den . ./templates/minimal`
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.

2 participants