Repository navigation
feat: built-in flake-parts entity kind - #543
Merged
Merged
Conversation
sini
force-pushed
the
feat/builtin-flake-parts-entity
branch
8 times, most recently
from
May 15, 2026 06:34
f349718 to
69fac9c
Compare
theutz
approved these changes
May 15, 2026
Collaborator
Author
|
Adding a update for #545 here as well |
The perSystem option only exists in flake-parts mkFlake contexts, not in denTest evalModules. Checking options ? perSystem causes infinite recursion. Instead, denTest sets __denTest specialArg and outputs.nix skips injection when it's present.
flakeModule now supports three modes:
inputs.den.flakeModule -- no bridging (backwards compat)
inputs.den.flakeModule true -- auto-discover outer options, bridge all
inputs.den.flakeModule ["flake-file"] -- explicit bridge keys
Auto-discovery uses builtins.attrNames options inside a { config = ... }
return, which avoids the module system's eager key enumeration cycle.
The inner flake evalModules has freeformType to capture routes at
arbitrary paths; den.lib.flakeRouted exposes the content lazily.
flakeModule auto-discovers declared top-level options and bridges
routed flake content to them. No manual bridging needed.
Uses builtins.attrNames options (config-free) inside { config = ... }
to avoid the module system's eager key enumeration cycle. Guarded on
inputs ? flake-parts to skip non-flake-parts contexts.
Route any path:
den.lib.policy.route { intoClass = "flake"; path = ["X" "Y"]; }
Content auto-arrives at config.X.Y in flake-parts.
For explicit key override: inputs.den.flakeBridge ["key"]
The flake-parts entity content flows naturally through route policies into perSystem.imports — the secondary evalModules with freeformType, hardcoded internalKeys filters, and mkIf/genAttrs bridge were unnecessary.
Restore __denTest sentinel — needed because nix-unit tests in flake-parts-modules evaluate through denTest where perSystem doesn't exist. Two separate guards: no-flake-parts (inputs only) controls the flakeOutputs import, has-flake-parts (inputs + sentinel) controls perSystem injection.
Transition policies now read as source-to-target: system-to-flake-parts, packages-to-flake-parts, devshell-to-flake-parts, treefmt-to-flake-parts, tests-to-flake-parts, files-to-flake-parts
to-systems → flake-to-systems to-os-outputs → system-to-os-outputs to-hm-outputs → system-to-hm-outputs to-packages → packages-to-flake to-apps → apps-to-flake to-checks → checks-to-flake to-devShells → devShells-to-flake to-legacyPackages → legacyPackages-to-flake Policy names now describe both source and destination, matching the convention established by host-to-users, system-to-flake-parts, and packages-to-flake-parts.
sini
force-pushed
the
feat/builtin-flake-parts-entity
branch
from
May 15, 2026 07:29
9cad81b to
78ef223
Compare
sini
enabled auto-merge (squash)
May 15, 2026 07:31
theutz
approved these changes
May 15, 2026
theutz
left a comment
Collaborator
There was a problem hiding this comment.
Nice. Oh, that's so much easier to understand for me. Thank you!
sini
disabled auto-merge
May 15, 2026 08:03
charlesfire
pushed a commit
to charlesfire/den
that referenced
this pull request
May 16, 2026
## Summary Makes flake-parts a built-in entity kind, eliminating ~80 lines of boilerplate users previously had to write for flake-parts integration (custom policies, manual `perSystem.imports` injection, `systems` derivation, `isEntity` flag). - Register `flake-parts` as unconditional schema kind - Define `system-to-flake-parts` and `packages-to-flake-parts` policies (guarded on `inputs ? flake-parts`, opt-in via schema wiring) - Auto-inject resolved flake-parts entity into `perSystem.imports` and set `systems = den.systems` - Simplify `flake-parts-modules` template: delete `flake-parts.nix` + `systems.nix`, simplify `packages.nix` from 23→4 lines, remove inline policy definitions from `den.nix` Fixes denful#545 — all shipped policy names now follow `source-to-target` convention: | Old | New | |-----|-----| | `to-systems` | `flake-to-systems` | | `to-os-outputs` | `system-to-os-outputs` | | `to-hm-outputs` | `system-to-hm-outputs` | | `to-packages` | `packages-to-flake` | | `to-apps` | `apps-to-flake` | | `to-checks` | `checks-to-flake` | | `to-devShells` | `devShells-to-flake` | | `to-legacyPackages` | `legacyPackages-to-flake` | **Design constraints:** no secondary pipeline, no hardcoded filter lists, no mkForce/merge overrides. Content flows naturally through route policies into `perSystem.imports`. ## User-facing change ```nix # Before: ~80 lines of boilerplate den.policies.to-flake-parts = { system, ... }: [ ... ]; den.schema.flake-parts.isEntity = true; perSystem.imports = [ (den.lib.aspects.resolve ...) ]; systems = builtins.attrNames den.hosts; # After: schema wiring only den.schema.flake-system.includes = [ den.policies.system-to-flake-parts ]; den.schema.flake-system.excludes = [ den.policies.packages-to-flake ]; den.schema.flake-parts.includes = [ den.policies.packages-to-flake-parts ]; ``` ## Test plan - [x] `nix develop -c just ci` — 808/808 tests pass - [x] `nix develop -c just check-all` — all templates pass - [x] Code review — no critical/important issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes flake-parts a built-in entity kind, eliminating ~80 lines of boilerplate users previously had to write for flake-parts integration (custom policies, manual
perSystem.importsinjection,systemsderivation,isEntityflag).flake-partsas unconditional schema kindsystem-to-flake-partsandpackages-to-flake-partspolicies (guarded oninputs ? flake-parts, opt-in via schema wiring)perSystem.importsand setsystems = den.systemsflake-parts-modulestemplate: deleteflake-parts.nix+systems.nix, simplifypackages.nixfrom 23→4 lines, remove inline policy definitions fromden.nixFixes #545 — all shipped policy names now follow
source-to-targetconvention:to-systemsflake-to-systemsto-os-outputssystem-to-os-outputsto-hm-outputssystem-to-hm-outputsto-packagespackages-to-flaketo-appsapps-to-flaketo-checkschecks-to-flaketo-devShellsdevShells-to-flaketo-legacyPackageslegacyPackages-to-flakeDesign constraints: no secondary pipeline, no hardcoded filter lists, no mkForce/merge overrides. Content flows naturally through route policies into
perSystem.imports.User-facing change
Test plan
nix develop -c just ci— 808/808 tests passnix develop -c just check-all— all templates pass