fake.modules transposition for aspect-oriented Dendritic Nix. with cross-aspect dependencies. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ dendrix.oeiuwq.com/Dendritic.html
dendritic nix aspect oriented

more docs

+8 -4
+6 -4
README.md
··· 186 186 187 187 When a module like `flake.modules.nixos.foo` is requested (for example, included in a `nixosConfiguration`), a corresponding module is computed from `flake.aspects.foo.nixos`. 188 188 189 - `flake.aspects.foo.includes` is a list of functions (providers) that are called with `{ aspect-chain = ["foo"]; class = "nixos" }`. These providers return another aspect that provides a module of the same `class` (in this case, `nixos`). 189 + `flake.aspects.foo.includes` is a list of functions (providers). A **provider** is a function `{ class, aspect-chain } => <aspect-object>`. They are called with `{ aspect-chain = ["foo"]; class = "nixos" }`. These providers return an aspect object that contains a module of the same `class` (in this case, `nixos`). 190 190 191 191 Providers answer the question: given we have `nixos` modules from `[foo]` aspects, what other aspects can provide `nixos` modules that need to be imported? 192 192 193 193 This means that the included aspect determines which configuration its caller should use. 194 194 195 - By default, all aspects have a `<aspect>.provides.itself` provider function that ignores its argument and returns the `<aspect>` itself. This is why `with aspects; [ bar baz ]` works: it is shorthand for `[ aspects.bar.provides.itself aspects.baz.provides.itself ]`. 195 + By default, all aspects have an `<aspect>.provides.itself` provider function that always returns the `<aspect>` itself. This is why `with aspects; [ bar baz ]` works: it is shorthand for `[ aspects.bar.provides.itself aspects.baz.provides.itself ]`. It is possible to override the default provider, by setting `__functor`, see how [test](https://github.com/vic/flake-aspects/blob/4f88b4ecefbe46ccfa5d9cfa11451a88be169a70/checkmate.nix#L270) or [vic/den](https://github.com/vic/den/blob/def1c396e7ce884578d6589391cca8a4c6a650d3/nix/aspects-config.nix#L55) do it. 196 196 197 197 ##### Dynamic modules using provider function's `{ aspect-chain, class }` argument. 198 198 199 - You can also define custom providers that inspect the `aspect-chain` and `class` arguments and return a set of modules accordingly. This allows providers to act as proxies or routers for dependencies. 199 + You can also define custom providers that inspect the `aspect-chain` and `class` values and return a set of modules accordingly. This allows providers to act as conditional proxies or routers for dependencies. 200 200 201 201 ```nix 202 202 flake.aspects.kde-desktop.provides.karousel = { aspect-chain, class }: ··· 213 213 214 214 ##### Parametrized modules from providers. 215 215 216 - Providers can be curried like any function, this way you can provide parametrized modules. 216 + Providers can be curried (but *must* use explicit argument names). This lets you have 217 + modules parametrized by some values, outside the aspect scope. For a real-world 218 + usage of this feature, see how `vic/den` [defines](https://github.com/vic/den/blob/def1c396e7ce884578d6589391cca8a4c6a650d3/nix/aspects-config.nix#L40) `flake.aspects.default.host` and their [use](https://github.com/vic/den/blob/def1c396e7ce884578d6589391cca8a4c6a650d3/templates/default/modules/_example/aspects.nix#L32). 217 219 218 220 ```nix 219 221 flake.aspects = { aspects, ... }: {
+2
nix/types.nix
··· 5 5 freeformType = lib.types.attrsOf aspectSubmodule; 6 6 }; 7 7 8 + # { class, aspect-chain } => aspect-object 9 + # _ => aspect-object 8 10 functionToAspect = lib.types.addCheck (lib.types.functionTo aspectSubmodule) ( 9 11 f: 10 12 let