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
1# This example implements an aspect "routing" pattern.
2#
3# Unlike `den.default` which is `parametric.atLeast`
4# we use `parametric.fixedTo` here, which help us
5# propagate an already computed context to all includes.
6#
7# This aspect, when installed in a `parametric.atLeast`
8# will just forward the same context.
9# The `mutual` helper returns an static configuration which
10# is ignored by parametric aspects, thus allowing
11# non-existing aspects to be just ignored.
12#
13# Be sure to read: https://vic.github.io/den/dependencies.html
14# See usage at: defaults.nix, alice.nix, igloo.nix
15#
16{ den, ... }:
17{
18 # Usage: `den.default.includes [ eg.routes ]`
19 eg.routes =
20 let
21 inherit (den.lib) parametric;
22
23 # eg, `<user>._.<host>` and `<host>._.<user>`
24 mutual = from: to: den.aspects.${from.aspect}._.${to.aspect} or { };
25
26 routes =
27 { host, user, ... }@ctx:
28 parametric.fixedTo ctx {
29 includes = [
30 (mutual user host)
31 (mutual host user)
32 ];
33 };
34 in
35 routes;
36}