Repository navigation
improve: migrate to gen-schema's options-first API; strict mode as a property of the kind - #717
Merged
Merged
Conversation
- bump gen in templates/ci to 591758a
- mkInstanceType takes its options first and the kind last, matching
gen-schema (`mkInstanceType { … } kind`)
- host, user and home take conf through `inherits`, replacing the
deprecated kind-value import
- fleet-demo builds its registry types with den.lib.schema.mkInstanceType;
a kind value is no longer importable into a plain types.submodule
Known failing: strict-mode (7 cells under nix-unit). gen-merge now refuses
to merge den.lib.strict's freeform type with the non-strict instance's
attrsOf anything.
den.lib.strict was a fake freeform type stacked on the kind's open
freeform, relying on nixpkgs letting a custom typeMerge return a non-type.
gen-merge refuses that join by name (it drops attrsOf's check), and nixpkgs
itself refuses the order den builds it in ("already declared").
- den.schema.<kind>.isStrict is a schema collection; den.lib.strict is the
entry `{ isStrict = true; }`
- host, user and home instance types pass it to gen-schema's
mkInstanceType `strict`
- the aspect submodule swaps its open freeform for gen-schema's
mkStrictModule; the flake submodule drops its freeform
- strict-mode expectations follow gen-schema's refusal text
Known failing: four strict-mode cells (aspect x2, flake x2). gen-schema
and gen-aspects add a gen-merge-only `__reservedKeys` marker to the kind
modules; it leaks into nixpkgs-mounted kinds, and a closed kind refuses it
before the planted key.
With the gen marker leak fixed, a strict aspect names its undeclared keys (including class keys den adds for a host, as before) and a strict flake refuses an undeclared option. Expectations now match that text.
…arnings - `den.schema.<kind>.imports = [ den.lib.strict ]` makes the kind strict again. It was silently a no-op after den.lib.strict became a schema entry. Strict instances declare a hidden `isStrict` option to absorb the stray definition the import leaves on each instance. - `den.lib.schema.mkInstanceType kind opts` dispatches on the closed option key set and flips to the options-first order.
- reference/lib: den.lib.strict (per-kind refusal text) and den.lib.schema.mkInstanceType (options-first, strict follows isStrict only when passed). - reference/lib-deprecated: the imports-form strict and kind-first mkInstanceType. - reference/schema: isStrict and inherits collections; host/user/home inherit conf. - acl-environments: registry types built with mkInstanceType, passing isStrict.
sini
marked this pull request as ready for review
October 7, 2026 15:27
The strict-import warning names the file that declares the import. The kind-first mkInstanceType warning names the kind. Both show the old and new spelling as a diff.
vic
pushed a commit
that referenced
this pull request
Oct 13, 2026
) (#720) Fixes #719. ## Cause Since #717, gen-schema mints a kind's identity from the contents of its schema collections when an instance is imported. `includes` and `excludes` hold aspect references, and an aspect reference can reach back into the host being built. Hashing the collection therefore forced that host during its own import. The result was an infinite recursion, or an exclusion that silently did nothing. ## Fix - `den.schema` declares `includes` and `excludes` with `identity = false`. gen-schema keeps a collection declared this way out of the kind identity. These collections are policy over aspects, not part of the kind's shape. - `templates/ci` pins gen at `6427d42`, which carries gen-schema `10f4d12` with `identity = false` support. Only the `gen` input moved (`nix flake update gen`). ## Tests `templates/ci/modules/deadbugs/issue-719-schema-excludes-aspect-ref.nix` now has 5 cells: - the 3 cells from the reproduction commit, which put a direct reference, a bracket reference and a nested bracket reference in `den.schema.host.excludes`; - 2 cells that put the same references in the parent kind's `den.schema.conf.excludes` / `includes`. The 2 `conf` cells expect the values den produced before #717, where `conf`'s collections do not apply to a host instance. I checked them against `65c9fd4` and all 5 cells pass there. `nix-unit --override-input den . --flake ./templates/ci#tests`: | tree | #719 suite | full suite | |---|---|---| | reproduction commit `39c4833` (old gen pin) | 0/3, infinite recursion | 1270/1273. The only failures are the 3 #719 cells | | this PR | 5/5 | 1275/1275 | | this PR without the `identity = false` lines | 0/5, infinite recursion | 1270/1275. The only failures are the 5 #719 cells | `just fmt` makes no changes.
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
Moves den to gen-schema's options-first API and redesigns strict mode, which the same gen bump broke.
Options-first migration
templates/cipins gen591758a.mkInstanceType { … } kind. den'smkInstanceTypewrapper (nix/lib/schema.nix) and the host, user and home entity types follow.confthroughinherits = [ den.schema.conf ]. Importing the kind value is the deprecated spelling, and gen-schema now warns on it.den.lib.schema.mkInstanceType. Importing a kind value into a plaintypes.submodulestill works at this gen pin (checked foruser,host,confand a customenvironmentkind), but that submodule stays open when the kind is strict.Strict mode
den.lib.strictused to be a second freeform type stacked on the kind's open one. ItstypeMergereturns{ merge = …throw… }, which is not a type, and it only worked because nixpkgs takes a customtypeMergeresult on trust. Even so, nixpkgs refuses the order den builds it in ("already declared"). den main passed only because an older gen-merge folded these types in the other order. gen-merge now folds the way nixpkgs does, and it refuses the join because the join dropsattrsOf's check.Strictness is now a property of the kind:
den.schema.<kind>.isStrictis a schema collection, andden.lib.strictis the entry{ isStrict = true; }.flakeModules.strictis unchanged.mkInstanceType'sstrict.mkStrictModule, and the flake submodule drops its freeform. The closed type replaces the open one rather than being merged with it.STRICT MODE: "arbitrary" is not declared on host (instance at den.hosts.x86_64-linux.igloo, …), and the tests expect it.explanation/entities.mdx) describe per-kind strictness.den.lib.strictis assigned to the entry itself.Compatibility
Both old spellings keep working and warn:
den.schema.<kind>.imports = [ den.lib.strict ]still makes the kind strict. Without the shim it was silently a no-op.computed.isStrictrecognisesden.lib.strictlisted directly in an entry'simports. Strict instances declare a hiddenisStrictoption, because the import also leavesisStrict = trueon each instance and the closed type would refuse it.den.lib.schema.mkInstanceType kind optsstill works. The options are a closed key set (extraModules,strict,specialArgs), so any other first argument is treated as a kind and the arguments are flipped.Each warning includes migration instructions. The strict one names the file that declares the import. The
mkInstanceTypeone names the kind; Nix can't report the caller's file. For example:Tests for both are in
deprecated/strict-imports.nix.User-facing API changes
den.schema.<kind>.isStrictcollection. den reads it forhost,user,home,aspectandflake. A registry of your own kind follows it only when it passesstrict = den.schema.<kind>.isStricttomkInstanceType.den.lib.strictis the entry{ isStrict = true; }, not a module.den.lib.schema.mkInstanceTypetakes the options first. The kind-first order is deprecated.confthroughinherits. Importing a kind value is deprecated in gen-schema and warns.STRICT MODE: "x" is not declared on <kind> (instance at …), naming every undeclared key. For flake it's the module system'sThe option `flake.x' does not exist.591758aor later for consumers that pin their owninputs.gen.Docs:
reference/lib(newden.lib.strictandden.lib.schemasections),reference/lib-deprecated,reference/schema(isStrictandinheritsrows),explanation/entitiesandguides/acl-environments(registry types rewritten tomkInstanceTypewithisStrict).Validation
templates/cipins gen hub4ab2a94, which includes the gen-schema and gen-aspects fixes for the__reservedKeysand__keyEqmarker leaks into nixpkgs-mounted kinds.nix-unit --flake ./templates/ci#.tests: 1270/1270 (the unmodified PR head gives 1264/1264 on the same machine), includingstrict-mode10/10,strict-imports5/5 andmkInstanceType-kind-first1/1.den.schema.environment.isStrict = true. Both behaved as documented.nixos). main does the same. The refusal now names every undeclared key instead of one.test-strict-mode-flake-customisablepassed before only by accident:den.lib.strictinsideimportsnever made the flake strict. It now usesden.schema.flake.isStrict = true.