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

aspect-chain contains aspect objects nor their names. (#8)

* aspect-chain contains aspect objects nor their names.

this is useful because we also have anonymous aspects
being the result of providers. even when these anonymous
aspect can be given an explicit name via `name` attribute,
it is better to pass the object itself.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

authored by oeiuwq.com

Copilot and committed by
GitHub
a58df91d b67c2539

+16 -11
+1 -1
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). 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`). 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 = [ aspects.foo ]; class = "nixos" }`, functions can inspect the chain of aspects that have led to the call. 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
+3 -3
checkmate.nix
··· 164 164 name = "aspectTwo.foo"; 165 165 description = "aspectTwo foo provided"; 166 166 includes = [ aspects.aspectThree.provides.moo ]; 167 - classOne.bar = [ "two:${class}:${lib.concatStringsSep "/" aspect-chain}" ]; 167 + classOne.bar = [ "two:${class}:${lib.concatStringsSep "/" (lib.map (x: x.name) aspect-chain)}" ]; 168 168 classTwo.bar = [ "foo class two not included" ]; 169 169 }; 170 170 provides.bar = _: { ··· 175 175 aspectThree.provides.moo = 176 176 { aspect-chain, class }: 177 177 { 178 - classOne.bar = [ "three:${class}:${lib.concatStringsSep "/" aspect-chain}" ]; 178 + classOne.bar = [ "three:${class}:${lib.concatStringsSep "/" (lib.map (x: x.name) aspect-chain)}" ]; 179 179 }; 180 180 }; 181 181 }; ··· 286 286 aspect.name 287 287 message 288 288 class 289 - ] ++ aspect-chain; 289 + ] ++ (lib.map (x: x.name) aspect-chain); 290 290 }; 291 291 aspectTwo.classOne.bar = [ "itself not included" ]; 292 292 };
+12 -7
nix/aspects.nix
··· 1 1 lib: aspects: 2 2 let 3 3 transpose = import ./. { inherit lib emit; }; 4 - emit = transposed: [ 5 - { 6 - inherit (transposed) parent child; 7 - value = aspectModule [ transposed.child ] transposed.parent aspects.${transposed.child}; 8 - } 9 - ]; 4 + emit = 5 + transposed: 6 + let 7 + aspect = aspects.${transposed.child}; 8 + in 9 + [ 10 + { 11 + inherit (transposed) parent child; 12 + value = aspectModule [ aspect ] transposed.parent aspect; 13 + } 14 + ]; 10 15 11 16 include = 12 17 aspect-chain: class: provider: 13 18 let 14 19 provided = provider { inherit aspect-chain class; }; 15 - new-chain = aspect-chain ++ [ provided.name ]; 20 + new-chain = aspect-chain ++ [ provided ]; 16 21 in 17 22 aspectModule new-chain class provided; 18 23