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

Ensure top-level aspects support parametric functions (#15)

and also funcion-to-module if lib,config,options detected.
Related: https://github.com/vic/den/issues/92

See:
https://github.com/vic/den/discussions/91#discussioncomment-14978857

authored by oeiuwq.com and committed by

GitHub 6a6d47f5 1941f184

+27 -4
+9 -3
checkmate.nix
··· 362 362 flake.aspects = 363 363 { aspects, ... }: 364 364 { 365 - aspectOne.includes = [ (aspects.aspectTwo { message = "hello"; }) ]; 366 - aspectOne.classOne = { }; # required for propagation 365 + aspectOne = 366 + { aspect, ... }: 367 + { 368 + includes = [ (aspects.aspectTwo { message = "hello ${aspect.name}"; }) ]; 369 + classOne = { }; # required for propagation 370 + }; 367 371 368 372 aspectTwo.__functor = 369 373 _: ··· 372 376 { aspect, ... }: 373 377 { 374 378 classOne.bar = [ 379 + "foo" 375 380 aspect.name 376 381 message 377 382 class ··· 383 388 384 389 expr = (evalMod "classOne" flake.modules.classOne.aspectOne).bar; 385 390 expected = [ 391 + "foo" 386 392 "<function body>" 387 - "hello" 393 + "hello aspectOne" 388 394 "classOne" 389 395 "aspectOne" 390 396 ];
+18 -1
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 ); ··· 31 31 32 32 functionProviderType = lib.types.either functionToAspect (lib.types.functionTo providerType); 33 33 providerType = lib.types.either functionProviderType aspectSubmodule; 34 + 35 + aspectSubmoduleAttrs = lib.types.addCheck aspectSubmodule ( 36 + m: (!builtins.isFunction m) || (isAspectSubmoduleFn m) 37 + ); 38 + isAspectSubmoduleFn = 39 + m: 40 + lib.pipe m [ 41 + lib.functionArgs 42 + lib.attrNames 43 + (lib.intersectLists [ 44 + "lib" 45 + "config" 46 + "options" 47 + "aspect" 48 + ]) 49 + (x: lib.length x > 0) 50 + ]; 34 51 35 52 aspectSubmodule = lib.types.submodule ( 36 53 {