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