gen-aspects
gen-aspects is aspect-oriented composition types for Nix module systems: a category-keyed
option type that lets a caller declare which keys of an attrset are class content, which are
nested sub-aspects, and how includes compose.
The problem it owns: a framework wants to let a value be “networking config” in one branch and
“a nested aspect that includes other aspects” in another, classified by a declared key rather than
by guessing from shape. gen-aspects is that classification surface — aspectsType, parameterized
by the key semantics a framework supplies.
Its type system is re-hosted on gen-merge rather than on nixpkgs: evalModuleTree, the structural
types and mkOption/mkMerge stand where lib.types and lib.evalModules used to, with leaf
checkers arriving from gen-types through merge. The grammar produces the aspect node set without
evalModules at all. It builds on gen-identity, gen-merge, gen-prelude and gen-schema. One roster
member builds on gen-aspects: gen-link, for cross-flake federation over the same category
classification.
Take it alone
Section titled “Take it alone”{ inputs.gen-aspects.url = "github:sini/gen-aspects"; outputs = { gen-aspects, ... }: { lib.aspects = gen-aspects.lib; # lib + gen-schema are wired in by the flake };}eval = lib.evalModules { modules = [{ options.aspects = lib.mkOption { type = aspects.aspectsType { keySemantics = { nixos = { category = "class"; }; homeManager = { category = "class"; }; }; }; default = { }; }; config.aspects.networking = { nixos.networking.hostName = "myhost"; nixos.networking.firewall.enable = true; }; }];};Palettes adapted from Catppuccin (Macchiato) (MIT), Tokyo Night (Apache-2.0), gruvbox (MIT), Catppuccin (Latte) (MIT), Rosé Pine (Dawn) (MIT).