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
1{ inputs, lib, ... }:
2let
3 targetNix = "${inputs.target}/nix";
4 targetLib = "${inputs.target}/nix/lib.nix";
5 targetMod = "${inputs.target}/nix/flakeModule.nix";
6
7 transpose = import targetNix { inherit lib; };
8
9 mkFlake =
10 mod:
11 inputs.flake-parts.lib.mkFlake
12 {
13 inputs.self = [ ];
14 }
15 {
16 systems = [ ];
17 imports = [
18 targetMod
19 inputs.flake-parts.flakeModules.modules
20 mod
21 (fooMod "aspectOne")
22 (fooMod "aspectTwo")
23 (fooMod "aspectThree")
24 ];
25 };
26
27 fooMod = aspect: {
28 imports = [
29 { flake.modules.classOne.${aspect}.imports = [ fooOpt ]; }
30 { flake.modules.classTwo.${aspect}.imports = [ fooOpt ]; }
31 { flake.modules.classThree.${aspect}.imports = [ fooOpt ]; }
32 ];
33 };
34
35 fooOpt = {
36 options.foo = lib.mkOption {
37 type = lib.types.str;
38 default = "<unset>";
39 };
40 options.bar = lib.mkOption {
41 type = lib.types.listOf lib.types.str;
42 default = [ ];
43 };
44 options.baz = lib.mkOption {
45 type = lib.types.lazyAttrsOf lib.types.str;
46 default = { };
47 };
48 };
49
50 evalMod =
51 class: mod:
52 (lib.evalModules {
53 inherit class;
54 modules = [ mod ];
55 }).config;
56in
57{
58 _module.args = {
59 inherit
60 transpose
61 targetLib
62 targetMod
63 targetNix
64 ;
65 inherit mkFlake evalMod fooOpt;
66 };
67}