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 flake.aspects = 363 { aspects, ... }: 364 { 365 - aspectOne.includes = [ (aspects.aspectTwo { message = "hello"; }) ]; 366 - aspectOne.classOne = { }; # required for propagation 367 368 aspectTwo.__functor = 369 _: ··· 372 { aspect, ... }: 373 { 374 classOne.bar = [ 375 aspect.name 376 message 377 class ··· 383 384 expr = (evalMod "classOne" flake.modules.classOne.aspectOne).bar; 385 expected = [ 386 "<function body>" 387 - "hello" 388 "classOne" 389 "aspectOne" 390 ];
··· 362 flake.aspects = 363 { aspects, ... }: 364 { 365 + aspectOne = 366 + { aspect, ... }: 367 + { 368 + includes = [ (aspects.aspectTwo { message = "hello ${aspect.name}"; }) ]; 369 + classOne = { }; # required for propagation 370 + }; 371 372 aspectTwo.__functor = 373 _: ··· 376 { aspect, ... }: 377 { 378 classOne.bar = [ 379 + "foo" 380 aspect.name 381 message 382 class ··· 388 389 expr = (evalMod "classOne" flake.modules.classOne.aspectOne).bar; 390 expected = [ 391 + "foo" 392 "<function body>" 393 + "hello aspectOne" 394 "classOne" 395 "aspectOne" 396 ];
+18 -1
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 ); ··· 31 32 functionProviderType = lib.types.either functionToAspect (lib.types.functionTo providerType); 33 providerType = lib.types.either functionProviderType aspectSubmodule; 34 35 aspectSubmodule = lib.types.submodule ( 36 {
··· 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 ); ··· 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) 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 + ]; 51 52 aspectSubmodule = lib.types.submodule ( 53 {