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.

fix: excludeAspect cascades to provider sub-aspects (#411)

`excludeAspect` now checks if the reference's `aspectPath` is a prefix
of the aspect's path. Excluding `monitoring` also excludes
`monitoring._.node-exporter`, `monitoring._.alerting`, etc.

authored by

Jason Bowman and committed by
GitHub
d267c458 d266c3a0

+42 -2
+14 -2
nix/lib/aspects/adapters.nix
··· 44 44 # Use instead of reference equality — resolved aspects are fresh attrsets. 45 45 aspectPath = a: (a.meta.provider or [ ]) ++ [ (a.name or "<anon>") ]; 46 46 47 - # Exclude by aspect reference. 48 - excludeAspect = ref: filter (a: aspectPath a != aspectPath ref); 47 + # Exclude by aspect reference. Also excludes aspects provided by the 48 + # reference (e.g., excluding monitoring also excludes monitoring._.node-exporter). 49 + excludeAspect = 50 + ref: 51 + let 52 + refPath = aspectPath ref; 53 + in 54 + filter ( 55 + a: 56 + let 57 + ap = aspectPath a; 58 + in 59 + ap != refPath && lib.take (builtins.length refPath) ap != refPath 60 + ); 49 61 50 62 # Substitute an aspect reference with a replacement. 51 63 substituteAspect =
+28
templates/ci/modules/features/aspect-path.nix
··· 124 124 } 125 125 ); 126 126 127 + # excludeAspect: excluding a parent also excludes its providers 128 + test-excludeAspect-cascades-to-providers = denTest ( 129 + { den, ... }: 130 + { 131 + den.aspects.monitoring = { 132 + nixos = { }; 133 + provides.node-exporter.nixos = { }; 134 + provides.alerting.nixos = { }; 135 + }; 136 + den.aspects.server.includes = with den.aspects; [ 137 + monitoring 138 + monitoring._.node-exporter 139 + monitoring._.alerting 140 + ]; 141 + den.aspects.server.meta.adapter = 142 + inherited: den.lib.aspects.adapters.excludeAspect den.aspects.monitoring inherited; 143 + 144 + expr = with den.lib.aspects; resolve.withAdapter adapters.trace "nixos" den.aspects.server; 145 + # monitoring and all its providers excluded 146 + expected.trace = [ 147 + "server" 148 + [ "~monitoring" ] 149 + [ "~node-exporter" ] 150 + [ "~alerting" ] 151 + ]; 152 + } 153 + ); 154 + 127 155 # substituteAspect: replaced include becomes tombstone + replacement 128 156 test-substituteAspect-replaces = denTest ( 129 157 { den, ... }: