Skip to content

fix: import-tree class resolution and _ alias on batteries - #512

Merged
sini merged 2 commits into
denful:mainfrom
sini:fix/import-tree-fx-pipeline
May 11, 2026
Merged

sini merged 2 commits into
denful:mainfrom
sini:fix/import-tree-fx-pipeline

Conversation

@sini

@sini sini commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • import-tree battery now scans _<class> directories eagerly via builtins.readDir instead of relying on the class scope parameter, which the fx-pipeline only provides once per scope (not once per class)
  • Batteries with __functor (import-tree, forward, etc.) now forward provides children and the _ alias in the mergeFunctions single-def fast path, matching mergeWithAspectMeta behavior

Test plan

  • 771/771 CI tests pass
  • andrewix config evaluates correctly — fileSystems."/" and "/boot" populated on andrew-laptop/andrew-pc
  • WSL hosts correctly have empty fileSystems (no _nixos dir)
  • import-tree.test-no-import-for-missing-dir passes (pathExists guard)
  • den._.import-tree._.host resolves correctly (no attribute '_' missing)

Two regressions from the fx-pipeline:

1. import-tree only resolved for scope class (e.g. homeManager) but
   never for other classes like nixos. The old resolver called the
   parametric __fn once per class; the fx-pipeline provides class from
   the scope handler, which only fires once. Fix: scan _<class>
   directories eagerly via builtins.readDir instead of relying on the
   class parameter.

2. The _ alias (provides shorthand) was missing on batteries with
   __functor (import-tree, forward, etc). lib.isFunction returns true
   for { __functor = ... } attrsets, routing them through
   mergeFunctions' single-def fast path which returned the raw attrset
   without provides forwarding or _ alias. Fix: forward provides
   children and add _ in the fast path.

Fixes fileSystems regression reported by andrewix.
@sini
sini requested a review from drupol May 11, 2026 17:49
@sini sini added the allow-ci allow all CI integration tests label May 11, 2026
@sini
sini enabled auto-merge (squash) May 11, 2026 18:02
@sini
sini merged commit 01249b0 into denful:main May 11, 2026
44 of 51 checks passed
charlesfire pushed a commit to charlesfire/den that referenced this pull request May 16, 2026
## Summary

- import-tree battery now scans `_<class>` directories eagerly via
`builtins.readDir` instead of relying on the `class` scope parameter,
which the fx-pipeline only provides once per scope (not once per class)
- Batteries with `__functor` (import-tree, forward, etc.) now forward
`provides` children and the `_` alias in the `mergeFunctions` single-def
fast path, matching `mergeWithAspectMeta` behavior

## Test plan

- [x] 771/771 CI tests pass
- [x] andrewix config evaluates correctly — `fileSystems."/"` and
`"/boot"` populated on andrew-laptop/andrew-pc
- [x] WSL hosts correctly have empty fileSystems (no `_nixos` dir)
- [x] `import-tree.test-no-import-for-missing-dir` passes (pathExists
guard)
- [x] `den._.import-tree._.host` resolves correctly (no `attribute '_'
missing`)
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