forked from
oeiuwq.com/den
Modular, context-aware and aspect-oriented dendritic Nix configurations.
Discussions: https://oeiuwq.zulipchat.com/join/nqp26cd4kngon6mo3ncgnuap/
1# it is possible for top-level aspects directly under
2# den.aspects to take a context argument.
3{ den, lib, ... }:
4let
5 # A module to test that toplevel had context.
6 topLevel = name: {
7 config.tops = name;
8 options.tops = lib.mkOption { type = lib.types.str; };
9 };
10in
11{
12
13 den.aspects.toplevel-user =
14 { user, ... }:
15 {
16 nixos.imports = [ (topLevel user.name) ];
17 };
18
19 den.aspects.toplevel-host =
20 { host, ... }:
21 {
22 homeManager.imports = [ (topLevel host.name) ];
23 };
24
25 den.aspects.rockhopper.includes = [
26 den.aspects.toplevel-host
27 ];
28
29 den.aspects.alice.includes = [
30 den.aspects.toplevel-user
31 ];
32
33 perSystem =
34 {
35 checkCond,
36 alice-at-rockhopper,
37 rockhopper,
38 ...
39 }:
40 {
41 checks.alice-toplevel-user = checkCond "alice toplevel param aspect" (
42 rockhopper.config.tops == "alice"
43 );
44
45 checks.alice-toplevel-host = checkCond "alice toplevel param aspect" (
46 alice-at-rockhopper.tops == "rockhopper"
47 );
48 };
49
50}