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

Compare changes

Choose any two refs to compare.

Changed files
+28 -13
checkmate
modules
nix
+2 -2
README.md
··· 274 274 ## Testing 275 275 276 276 ```shell 277 - nix run ./checkmate#fmt --override-input target . 278 - nix flake check ./checkmate --override-input target . -L 277 + nix run github:vic/checkmate#fmt --override-input target . 278 + nix flake check github:vic/checkmate --override-input target . -L 279 279 ```
+4 -2
checkmate/modules/tests/aspect_assignment.nix
··· 50 50 ]; 51 51 }; 52 52 53 - expr = second.config.x; 53 + # Sort and dedupe for deterministic comparison - merged modules may 54 + # produce duplicates and order is not guaranteed across merges. 55 + expr = lib.sort (a: b: a < b) (lib.unique second.config.x); 54 56 expected = [ 55 - "foo" 56 57 "bar" 57 58 "baz" 59 + "foo" 58 60 ]; 59 61 in 60 62 {
+22 -9
nix/types.nix
··· 5 5 aspectsType = lib.types.submodule ( 6 6 { config, ... }: 7 7 { 8 - freeformType = lib.types.attrsOf providerType; 8 + freeformType = lib.types.attrsOf (lib.types.either aspectSubmoduleAttrs providerType); 9 9 config._module.args.aspects = config; 10 10 } 11 11 ); ··· 30 30 ); 31 31 32 32 functionProviderType = lib.types.either functionToAspect (lib.types.functionTo providerType); 33 - providerType = lib.types.either aspectSubmoduleAttrs functionProviderType; 33 + providerType = lib.types.either functionProviderType aspectSubmodule; 34 34 35 35 aspectSubmoduleAttrs = lib.types.addCheck aspectSubmodule ( 36 36 m: (!builtins.isFunction m) || (isAspectSubmoduleFn m) ··· 49 49 (x: lib.length x > 0) 50 50 ]; 51 51 52 + ignoredType = lib.types.mkOptionType { 53 + name = "ignored type"; 54 + description = "ignored values"; 55 + merge = _loc: _defs: null; 56 + check = _: true; 57 + }; 58 + 52 59 aspectSubmodule = lib.types.submodule ( 53 60 { 54 61 name, 55 - aspect, 56 62 config, 57 63 ... 58 64 }: ··· 78 84 options.provides = lib.mkOption { 79 85 description = "Providers of aspect for other aspects"; 80 86 default = { }; 81 - type = aspectsType; 87 + type = lib.types.submodule ( 88 + { config, ... }: 89 + { 90 + freeformType = lib.types.attrsOf providerType; 91 + config._module.args.aspects = config; 92 + } 93 + ); 82 94 }; 83 95 options.__functor = lib.mkOption { 84 96 internal = true; ··· 96 108 visible = false; 97 109 readOnly = true; 98 110 description = "resolved modules from this aspect"; 99 - type = lib.types.attrsOf lib.types.deferredModule; 100 - default = lib.mapAttrs (class: _: aspect.resolve { inherit class; }) aspect; 111 + type = ignoredType; 112 + apply = _: lib.mapAttrs (class: _: config.resolve { inherit class; }) config; 101 113 }; 102 114 options.resolve = lib.mkOption { 103 115 internal = true; 104 116 visible = false; 105 117 readOnly = true; 106 118 description = "function to resolve a module from this aspect"; 107 - type = lib.types.functionTo lib.types.deferredModule; 108 - default = 119 + type = ignoredType; 120 + apply = 121 + _: 109 122 { 110 123 class, 111 124 aspect-chain ? [ ], 112 125 }: 113 - resolve class aspect-chain (aspect { 126 + resolve class aspect-chain (config { 114 127 inherit class aspect-chain; 115 128 }); 116 129 };