Skip to content

API Reference

The flake exposes three entry points:

{
# Default functor: (lib) → { transpose, types, aspects, new, new-scope, forward }
__functor = _: import ./nix;
# flake-parts module: creates flake.aspects → flake.modules
flakeModule = ./nix/flakeModule.nix;
# Library API: (lib) → { transpose, types, aspects, new, new-scope, forward }
lib = import ./nix/lib.nix;
}

Usage: flake-aspects.lib nixpkgs.lib or import ./nix/lib.nix lib.

Source: nix/lib.nix

Source: nix/default.nix

Generic 2-level transposition. Returns a function attrs → transposed-attrs.

ParameterTypeDefaultPurpose
emit{ child, parent, value } → [{ parent, child, value }]lib.singletonHook for filtering, modifying, or multiplying items

See Transpose concept.

Source: nix/types.nix

Returns { aspectsType, aspectSubmodule, providerType }.

See Type System reference.

Source: nix/aspects.nix

aspects : lib → aspectsConfig → { transposed }.

Aspect-aware transposition. Supplies a custom emit to transpose that calls resolve on each item. Returns { transposed = { <class>.<aspect> = resolved-module; }; }.

Source: nix/new.nix

new : lib → (option → transposed → moduleDefinition) → aspectsConfig → moduleDefinition.

Low-level scope factory. The callback receives:

  • option — an mkOption for aspectsType (the user-facing input)
  • transposed — the resolved { <class>.<aspect> } output

Source: nix/new-scope.nix

new-scope : name → nixos-module.

Creates ${name}.aspects (input) and ${name}.modules (read-only output). Sugar over new. See Standalone guide.

Source: nix/forward.nix

forward : lib → { each, fromClass, intoClass, intoPath, fromAspect } → aspect.

Cross-class module forwarding. See Forward guide.

Source: nix/flakeModule.nix

A flake-parts module. Import it to get flake.aspects (input) → flake.modules (output). Uses new internally. See flake-parts guide.

Contribute Community Sponsor