Modular, context-aware and aspect-oriented dendritic Nix configurations. Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/ den.oeiuwq.com
configurations den dendritic nix aspect oriented
at cross 81 lines 1.8 kB view raw
1{ 2 inputs, 3 lib, 4 ns, 5 # deadnix: skip 6 __findFile ? __findFile, 7 ... 8}: 9let 10 treeModule.nixos.options.tree = lib.mkOption { 11 type = lib.types.listOf lib.types.str; 12 }; 13 inputX = { 14 denful.ns.root = { 15 nixos.tree = [ "X-root" ]; 16 provides.branch.nixos.tree = [ "X-branch" ]; 17 provides.branch.provides.leaf.nixos.tree = [ "X-leaf" ]; 18 }; 19 }; 20 inputY = { 21 denful.ns.root = { 22 nixos.tree = [ "Y-root" ]; 23 provides.branch.nixos.tree = [ "Y-branch" ]; 24 provides.branch.provides.leaf.nixos.tree = [ "Y-leaf" ]; 25 }; 26 }; 27in 28{ 29 30 imports = [ 31 (inputs.den.namespace "ns" [ 32 true 33 inputX 34 inputY 35 ]) 36 ]; 37 38 ns.root = { 39 nixos.tree = [ "local-root" ]; 40 provides.branch.nixos.tree = [ "local-branch" ]; 41 provides.branch.provides.leaf.nixos.tree = [ "local-leaf" ]; 42 }; 43 44 den.aspects.rockhopper.includes = [ 45 treeModule 46 <ns/root> 47 <ns/root/branch> 48 <ns/root/branch/leaf> 49 ]; 50 51 perSystem = 52 { checkCond, rockhopper, ... }: 53 let 54 vals = lib.sort (a: b: a < b) rockhopper.config.tree; 55 in 56 { 57 checks.ns-angle-bracket-root = checkCond "angle-bracket access root" (<ns/root> == ns.root); 58 59 checks.ns-angle-bracket-branch = checkCond "angle-bracket access branch" ( 60 <ns/root/branch> == ns.root._.branch 61 ); 62 63 checks.ns-angle-bracket-leaf = checkCond "angle-bracket access leaf" ( 64 <ns/root/branch/leaf> == ns.root._.branch._.leaf 65 ); 66 67 checks.ns-tree-all-levels-merged = checkCond "all tree levels merged" ( 68 vals == [ 69 "X-branch" 70 "X-leaf" 71 "X-root" 72 "Y-branch" 73 "Y-leaf" 74 "Y-root" 75 "local-branch" 76 "local-leaf" 77 "local-root" 78 ] 79 ); 80 }; 81}