| name | flake-aspects |
| description | Use this skill for any modular Nix configuration (flake-parts, NixOS, Darwin, Home-Manager). Essential for using the `<aspect>.<class>` transposition for cleaner dependencies, cross-aspect dependencies via `includes`, and parametric providers. Trigger this skill whenever you need to architect modular Nix code using Dendritic patterns, transpose aspect-based modular configs to `flake.modules`, or manage complex cross-aspect dependency graphs. |
flake-aspects
flake-aspects is a powerful, dependency-free Nix library that simplifies complex configuration by transposing intuitive <aspect>.<class> structures into the standard flake.modules.<class>.<aspect> layout required by many Nix tools.
When to use (Trigger me!)
- Architecting Modular Nix: When you want to nest classes inside aspects for cleaner, more intuitive mental models.
- Dependency Graphs: When aspects need to depend on other aspects (
includes), forming a DAG.
- Parametric Configurations: When you need curried providers,
__functor overrides, or passing arguments at inclusion time.
- Interoperability: When targeting multiple configuration classes (NixOS, Darwin, Home-Manager, NixVim, Terranix) within a single aspect.
- Zero-Dependency Requirements: When working with or without flakes (standalone evaluation).
Key Concepts
flake.aspects: The native, transposed definition structure (.<aspect>.<class>).
transpose: The primitive that transforms the tree/graph structure into flake.modules.
- Dependency Mapping:
includes: Graph structure for cross-aspect dependencies.
provides (alias _): Tree structure for nestable sub-aspects.
- Advanced Features:
- Parametric Providers (curried functions).
- Context-aware
__functor override.
- Cross-class forwarding.
Examples & Patterns
Aspect Definition and Transposition
Define your modules in a nested, intuitive structure:
flake.aspects = {
vim-btw = {
nixos = { ... };
darwin = { ... };
homeManager = { ... };
};
tiling-desktop = {
# Includes vim-btw as a dependency
includes = [ aspects.vim-btw ];
nixos = { ... };
};
};
# Resulting flake.modules (automatically generated by transpose)
# {
# nixos.vim-btw = { imports = [ ... ]; };
# nixos.tiling-desktop = { imports = [ nixos-config, vim-btw-nixos ]; };
# darwin.vim-btw = { imports = [ ... ]; };
# }
Workflow Pattern (Mandatory)
- Define: Create your modular structure in
flake.aspects within your flake-parts configuration.
- Transpose: Use the library to transform
flake.aspects -> flake.modules.
- Link: Apply
includes to manage inter-aspect data flow.
- Parametrize: Use currying or
__functor for dynamic configurations.
Troubleshooting
- If modules aren't being picked up by
flake-parts, ensure transpose is correctly hooked into the flake-parts module.
- For cross-aspect dependency issues, visualize the dependency DAG — ensure no circular dependencies exist.