tangled
alpha
login
or
join now
oeiuwq.com
/
den
8
fork
atom
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
atom
overview
issues
4
pulls
2
pipelines
namespace tests (#136)
authored by
oeiuwq.com
and committed by
GitHub
1 month ago
206096e5
d5b7fc68
+212
3 changed files
expand all
collapse all
unified
split
templates
examples
modules
_example
ci
angle-bracket-deep.nix
deep-nested-namespace.nix
shared-parametric-aspects.nix
+81
templates/examples/modules/_example/ci/angle-bracket-deep.nix
···
1
1
+
{
2
2
+
inputs,
3
3
+
lib,
4
4
+
ns,
5
5
+
# deadnix: skip
6
6
+
__findFile ? __findFile,
7
7
+
...
8
8
+
}:
9
9
+
let
10
10
+
treeModule.nixos.options.tree = lib.mkOption {
11
11
+
type = lib.types.listOf lib.types.str;
12
12
+
};
13
13
+
inputX = {
14
14
+
denful.ns.root = {
15
15
+
nixos.tree = [ "X-root" ];
16
16
+
provides.branch.nixos.tree = [ "X-branch" ];
17
17
+
provides.branch.provides.leaf.nixos.tree = [ "X-leaf" ];
18
18
+
};
19
19
+
};
20
20
+
inputY = {
21
21
+
denful.ns.root = {
22
22
+
nixos.tree = [ "Y-root" ];
23
23
+
provides.branch.nixos.tree = [ "Y-branch" ];
24
24
+
provides.branch.provides.leaf.nixos.tree = [ "Y-leaf" ];
25
25
+
};
26
26
+
};
27
27
+
in
28
28
+
{
29
29
+
30
30
+
imports = [
31
31
+
(inputs.den.namespace "ns" [
32
32
+
true
33
33
+
inputX
34
34
+
inputY
35
35
+
])
36
36
+
];
37
37
+
38
38
+
ns.root = {
39
39
+
nixos.tree = [ "local-root" ];
40
40
+
provides.branch.nixos.tree = [ "local-branch" ];
41
41
+
provides.branch.provides.leaf.nixos.tree = [ "local-leaf" ];
42
42
+
};
43
43
+
44
44
+
den.aspects.rockhopper.includes = [
45
45
+
treeModule
46
46
+
<ns/root>
47
47
+
<ns/root/branch>
48
48
+
<ns/root/branch/leaf>
49
49
+
];
50
50
+
51
51
+
perSystem =
52
52
+
{ checkCond, rockhopper, ... }:
53
53
+
let
54
54
+
vals = lib.sort (a: b: a < b) rockhopper.config.tree;
55
55
+
in
56
56
+
{
57
57
+
checks.ns-angle-bracket-root = checkCond "angle-bracket access root" (<ns/root> == ns.root);
58
58
+
59
59
+
checks.ns-angle-bracket-branch = checkCond "angle-bracket access branch" (
60
60
+
<ns/root/branch> == ns.root._.branch
61
61
+
);
62
62
+
63
63
+
checks.ns-angle-bracket-leaf = checkCond "angle-bracket access leaf" (
64
64
+
<ns/root/branch/leaf> == ns.root._.branch._.leaf
65
65
+
);
66
66
+
67
67
+
checks.ns-tree-all-levels-merged = checkCond "all tree levels merged" (
68
68
+
vals == [
69
69
+
"X-branch"
70
70
+
"X-leaf"
71
71
+
"X-root"
72
72
+
"Y-branch"
73
73
+
"Y-leaf"
74
74
+
"Y-root"
75
75
+
"local-branch"
76
76
+
"local-leaf"
77
77
+
"local-root"
78
78
+
]
79
79
+
);
80
80
+
};
81
81
+
}
+78
templates/examples/modules/_example/ci/deep-nested-namespace.nix
···
1
1
+
{
2
2
+
inputs,
3
3
+
lib,
4
4
+
deep,
5
5
+
...
6
6
+
}:
7
7
+
let
8
8
+
deepModule.nixos.options.deepVals = lib.mkOption {
9
9
+
type = lib.types.listOf lib.types.str;
10
10
+
};
11
11
+
depthA = {
12
12
+
denful.deep.a._.b._.c._.d._.e = {
13
13
+
description = "5 levels deep from inputA";
14
14
+
nixos.deepVals = [ "inputA-5-levels" ];
15
15
+
provides.f.nixos.deepVals = [ "inputA-6-levels" ];
16
16
+
};
17
17
+
};
18
18
+
depthB = {
19
19
+
denful.deep.a._.b._.c._.d._.e = {
20
20
+
nixos.deepVals = [ "inputB-5-levels" ];
21
21
+
provides.f.nixos.deepVals = [ "inputB-6-levels" ];
22
22
+
};
23
23
+
};
24
24
+
in
25
25
+
{
26
26
+
imports = [
27
27
+
(inputs.den.namespace "deep" [
28
28
+
true
29
29
+
depthA
30
30
+
depthB
31
31
+
])
32
32
+
];
33
33
+
34
34
+
deep.a._.b._.c._.d._.e = {
35
35
+
nixos.deepVals = [ "local-5-levels" ];
36
36
+
provides.f.nixos.deepVals = [ "local-6-levels" ];
37
37
+
};
38
38
+
39
39
+
den.aspects.rockhopper.includes = [
40
40
+
deepModule
41
41
+
deep.a._.b._.c._.d._.e
42
42
+
deep.a._.b._.c._.d._.e._.f
43
43
+
];
44
44
+
45
45
+
perSystem =
46
46
+
{ checkCond, rockhopper, ... }:
47
47
+
let
48
48
+
vals = lib.sort (a: b: a < b) rockhopper.config.deepVals;
49
49
+
in
50
50
+
{
51
51
+
checks.deep-nest-5-levels = checkCond "5 levels deep merged correctly" (
52
52
+
builtins.elem "inputA-5-levels" vals
53
53
+
&& builtins.elem "inputB-5-levels" vals
54
54
+
&& builtins.elem "local-5-levels" vals
55
55
+
);
56
56
+
57
57
+
checks.deep-nest-6-levels = checkCond "6 levels deep merged correctly" (
58
58
+
builtins.elem "inputA-6-levels" vals
59
59
+
&& builtins.elem "inputB-6-levels" vals
60
60
+
&& builtins.elem "local-6-levels" vals
61
61
+
);
62
62
+
63
63
+
checks.deep-nest-all-merged = checkCond "all values merged" (
64
64
+
vals == [
65
65
+
"inputA-5-levels"
66
66
+
"inputA-6-levels"
67
67
+
"inputB-5-levels"
68
68
+
"inputB-6-levels"
69
69
+
"local-5-levels"
70
70
+
"local-6-levels"
71
71
+
]
72
72
+
);
73
73
+
74
74
+
checks.deep-nest-flake-output = checkCond "deep namespace as flake output" (
75
75
+
inputs.self.denful.deep.a._.b._.c._.d._.e._.f == deep.a._.b._.c._.d._.e._.f
76
76
+
);
77
77
+
};
78
78
+
}
+53
templates/examples/modules/_example/ci/shared-parametric-aspects.nix
···
1
1
+
{
2
2
+
inputs,
3
3
+
lib,
4
4
+
shared,
5
5
+
...
6
6
+
}:
7
7
+
let
8
8
+
dataModule.nixos.options.data = lib.mkOption {
9
9
+
type = lib.types.listOf lib.types.str;
10
10
+
};
11
11
+
mkInputFlake = name: {
12
12
+
denful.shared.gaming._.retro._.sega = {
13
13
+
nixos.data = [ "${name}-sega-static" ];
14
14
+
};
15
15
+
};
16
16
+
inputFoo = mkInputFlake "foo";
17
17
+
inputBar = mkInputFlake "bar";
18
18
+
in
19
19
+
{
20
20
+
imports = [
21
21
+
(inputs.den.namespace "shared" [
22
22
+
true
23
23
+
inputFoo
24
24
+
inputBar
25
25
+
])
26
26
+
];
27
27
+
28
28
+
shared.gaming._.retro._.sega.nixos.data = [ "local-sega-static" ];
29
29
+
30
30
+
den.aspects.rockhopper.includes = [
31
31
+
dataModule
32
32
+
shared.gaming._.retro._.sega
33
33
+
];
34
34
+
35
35
+
perSystem =
36
36
+
{ checkCond, rockhopper, ... }:
37
37
+
let
38
38
+
vals = lib.sort (a: b: a < b) rockhopper.config.data;
39
39
+
in
40
40
+
{
41
41
+
checks.shared-parametric-all-merged = checkCond "all parametric merged" (
42
42
+
vals == [
43
43
+
"bar-sega-static"
44
44
+
"foo-sega-static"
45
45
+
"local-sega-static"
46
46
+
]
47
47
+
);
48
48
+
49
49
+
checks.shared-flake-output-matches = checkCond "flake output matches" (
50
50
+
shared.gaming._.retro._.sega == inputs.self.denful.shared.gaming._.retro._.sega
51
51
+
);
52
52
+
};
53
53
+
}