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
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(ctx): Aspect contributions can access source and target contexts (#356)

Usage Example:


```nix
# foo -> [bar]
den.ctx.foo.into.bar = { foo }: [ { bar = 22; } ];

# aspect for configuring foo
den.ctx.foo.provides.foo = { foo }: <aspect>;

# aspect for configuring bar
den.ctx.bar.provides.bar = { bar }: <aspect>;

# NEW: foo contributes configuration to bar
# The aspect here can read from both source and target contexts
den.ctx.foo.provides.bar = { foo }: { bar }: <aspect>;
```

authored by

Victor Borja and committed by
GitHub
2afa0546 e9624ff6

+21 -13
+1 -1
modules/outputs/flakeSystemOutputs.nix
··· 42 42 43 43 ctxs = map (output: { 44 44 flake-system.into."flake-${output}" = systemOutput output; 45 - flake-system.provides."flake-${output}" = systemOutputFwd; 45 + flake-system.provides."flake-${output}" = _: systemOutputFwd; 46 46 }) outputs; 47 47 in 48 48 ctxs;
+1 -1
modules/outputs/hmConfigurations.nix
··· 4 4 ctx.flake-system.into.flake-hm = 5 5 { system }: map (home: { inherit home; }) (builtins.attrValues den.homes.${system} or { }); 6 6 7 - ctx.flake-system.provides.flake-hm = hmFwd; 7 + ctx.flake-system.provides.flake-hm = _: hmFwd; 8 8 9 9 hmFwd = 10 10 { home }:
+1 -1
modules/outputs/osConfigurations.nix
··· 3 3 ctx.flake-system.into.flake-os = 4 4 { system }: map (host: { inherit host; }) (builtins.attrValues den.hosts.${system} or { }); 5 5 6 - ctx.flake-system.provides.flake-os = osFwd; 6 + ctx.flake-system.provides.flake-os = _: osFwd; 7 7 8 8 osFwd = 9 9 { host }:
+6 -6
nix/lib/ctx-apply.nix
··· 38 38 ); 39 39 40 40 transformAll = 41 - source: self: ctxValue: key: 41 + source: ctxPrev: self: ctxValue: key: 42 42 [ 43 43 { 44 + inherit source ctxPrev key; 44 45 ctx = ctxValue; 45 - inherit source key; 46 46 ctxDef = self; 47 47 } 48 48 ] ··· 51 51 let 52 52 target = lib.attrByPath path null ctxNs; 53 53 tkey = lib.concatStringsSep "." path; 54 - recurse = t: k: lib.concatMap (v: transformAll self t v k) into; 54 + recurse = t: k: lib.concatMap (v: transformAll self ctxValue t v k) into; 55 55 in 56 56 if target != null then 57 57 recurse target tkey ··· 69 69 70 70 noop = _: { }; 71 71 72 - crossProvider = p: p.source.provides.${p.key} or noop; 72 + crossProvider = p: p.source.provides.${p.key} or (_: noop); 73 73 74 74 buildIncludes = 75 75 items: ··· 80 80 clean = cleanCtx p.ctxDef; 81 81 isFirst = !(acc.seen ? ${p.key}); 82 82 selfFun = p.ctxDef.provides.${p.ctxDef.name} or noop; 83 - crossFun = crossProvider p; 83 + crossFun = crossProvider p p.ctxPrev; 84 84 in 85 85 { 86 86 seen = acc.seen // { ··· 99 99 } items).result; 100 100 101 101 ctxApply = self: ctxValue: { 102 - includes = buildIncludes (transformAll null self ctxValue self.name); 102 + includes = buildIncludes (transformAll null null self ctxValue self.name); 103 103 }; 104 104 105 105 in
+2
templates/ci/modules/features/context/cross-provider.nix
··· 17 17 funny.names = [ "parent-${x}" ]; 18 18 }; 19 19 den.ctx.parent._.child = 20 + _: 20 21 { x, y }: 21 22 { 22 23 funny.names = [ "parent-for-child-${x}-${y}" ]; ··· 60 61 funny.names = [ x ]; 61 62 }; 62 63 den.ctx.src._.dst = 64 + _: 63 65 { x, i }: 64 66 { 65 67 funny.names = [ "src-for-${x}-${toString i}" ];
+2
templates/ci/modules/features/context/named-provider.nix
··· 52 52 53 53 den.ctx.greet.into.other = lib.singleton; 54 54 den.ctx.greet.provides.other = 55 + _: 55 56 { who }: 56 57 { 57 58 funny.names = [ "other-${who}" ]; ··· 130 131 }; 131 132 132 133 den.ctx.greet.provides.num = 134 + _: 133 135 { number }: 134 136 { 135 137 funny.names = [ ("num:" + lib.toString number) ];
+2
templates/ci/modules/features/context/nested-ctx-providers.nix
··· 20 20 }; 21 21 22 22 den.ctx.root.provides.${"ns.inner"} = 23 + _: 23 24 { z }: 24 25 { 25 26 funny.names = [ "root-for-inner-${z}" ]; ··· 54 55 }; 55 56 56 57 den.ctx.root.provides.${"a.leaf"} = 58 + _: 57 59 { v }: 58 60 { 59 61 funny.names = [ "cross-a-${v}" ];
+3 -2
templates/ci/modules/features/den-as-lib.nix
··· 88 88 }; 89 89 den.ctx.foo.into.bar = { name }: lib.singleton { shout = lib.toUpper name; }; 90 90 den.ctx.foo.provides.bar = 91 + { name }: 91 92 { shout }: 92 93 { 93 - my.names = [ "foo shouted ${shout}" ]; 94 + my.names = [ "foo ${name} shouted ${shout}" ]; 94 95 }; 95 96 96 97 den.ctx.bar.provides.bar = ··· 115 116 116 117 expr = ev2.config.names; 117 118 expected = [ 118 - "foo shouted GOOD" 119 + "foo good shouted GOOD" 119 120 "bar GOOD" 120 121 "foo good" 121 122 ];
+1 -1
templates/ci/modules/features/perf/ctx-pipeline.nix
··· 55 55 }; 56 56 into = lib.genAttrs (lib.genList (i: "t${toString i}") n) (_: { v }: [ { v = "${v}!"; } ]); 57 57 provides = lib.genAttrs (lib.genList (i: "t${toString i}") n) ( 58 - name: 58 + name: _: 59 59 { v }: 60 60 { 61 61 funny.names = [ "cross-${name}-${v}" ];
+1 -1
templates/flake-parts-modules/modules/perSystem-forward.nix
··· 18 18 ); 19 19 20 20 ctx.flake-parts = { }; 21 - ctx.flake-parts-system.provides.flake-parts-system = perSystemFwd; 21 + ctx.flake-parts-system.provides.flake-parts-system = _: perSystemFwd; 22 22 perSystemModule = den.lib.aspects.resolve "flake-parts" (den.ctx.flake-parts { }); 23 23 in 24 24 {
+1
templates/microvm/modules/microvm-integration.nix
··· 58 58 # aspect configuring a guest vm at the host level (Declarative in MicroVM parlance) 59 59 # See: https://microvm-nix.github.io/microvm.nix/declarative.html 60 60 ctx.microvm-host.provides.microvm-guest = 61 + { host }: 61 62 { host, vm }: 62 63 { 63 64 includes =