Type System
Source: nix/types.nix
Exported types
Section titled “Exported types”| Type | Purpose |
|---|---|
aspectsType | Top-level container for all aspects. Used as the type for flake.aspects. |
aspectSubmodule | Individual aspect definition with class configs, includes, provides. |
providerType | Union of all valid provider shapes (functions and aspect attrsets). |
aspectsType
Section titled “aspectsType”A submodule with freeformType = lazyAttrsOf (either aspectSubmodule providerType).
Provides a fixpoint: _module.args.aspects = config — so aspect definitions can reference siblings via the aspects argument.
flake.aspects = { aspects, ... }: { a.includes = [ aspects.b ]; b.nixos = { };};Top-level entries can be either aspectSubmodule values (with submodule-style function args like { lib, config, options, aspect }) or providerType values (curried or direct provider functions).
aspectSubmodule
Section titled “aspectSubmodule”A submodule defining a single aspect. Key options:
| Option | Type | Default | Description |
|---|---|---|---|
name | str | attribute name | Aspect name, auto-set |
description | str | "Aspect ${name}" | Human description |
includes | listOf providerType | [] | Dependency providers |
provides / _ | submodule (freeform) | {} | Nested sub-aspects |
__functor | self → context → provider | identity | Override resolution behavior |
resolve | internal | — | { class, aspect-chain? } → module |
modules | internal | — | { <class> = module } lazy attrset |
The freeformType = lazyAttrsOf deferredModule means any key not listed above is treated as a class name with a deferred module value.
_ is an alias for provides (via mkAliasOptionModule).
The provides submodule also receives a fixpoint: _module.args.aspects = config — providers can reference siblings.
providerType
Section titled “providerType”A union type covering all valid provider shapes:
providerType = either providerFn aspectSubmoduleWhere providerFn = either directProviderFn curriedProviderFn:
directProviderFn: a function whose args are exactly{ class },{ aspect-chain }, or{ class, aspect-chain }.curriedProviderFn: any other function that returns aproviderType.
The distinction is made by isProviderFn which inspects functionArgs:
- If the function takes exactly
classand/oraspect-chain(and nothing else), it’s a direct provider. - Otherwise, it’s treated as curried — the user must call it with arguments first.
Internal types
Section titled “Internal types”| Type | Purpose |
|---|---|
ignoredType | For computed values that only exist during evaluation. Merges to null. |
mkInternal | Helper to create internal, invisible, read-only options with an apply function. |
isSubmoduleFn | Checks if a function has submodule-style args (lib, config, options, aspect). |