+2
-2
README.md
+2
-2
README.md
+4
-2
checkmate/modules/tests/aspect_assignment.nix
+4
-2
checkmate/modules/tests/aspect_assignment.nix
+22
-9
nix/types.nix
+22
-9
nix/types.nix
···
5
aspectsType = lib.types.submodule (
6
{ config, ... }:
7
{
8
-
freeformType = lib.types.attrsOf providerType;
9
config._module.args.aspects = config;
10
}
11
);
···
30
);
31
32
functionProviderType = lib.types.either functionToAspect (lib.types.functionTo providerType);
33
-
providerType = lib.types.either aspectSubmoduleAttrs functionProviderType;
34
35
aspectSubmoduleAttrs = lib.types.addCheck aspectSubmodule (
36
m: (!builtins.isFunction m) || (isAspectSubmoduleFn m)
···
49
(x: lib.length x > 0)
50
];
51
52
aspectSubmodule = lib.types.submodule (
53
{
54
name,
55
-
aspect,
56
config,
57
...
58
}:
···
78
options.provides = lib.mkOption {
79
description = "Providers of aspect for other aspects";
80
default = { };
81
-
type = aspectsType;
82
};
83
options.__functor = lib.mkOption {
84
internal = true;
···
96
visible = false;
97
readOnly = true;
98
description = "resolved modules from this aspect";
99
-
type = lib.types.attrsOf lib.types.deferredModule;
100
-
default = lib.mapAttrs (class: _: aspect.resolve { inherit class; }) aspect;
101
};
102
options.resolve = lib.mkOption {
103
internal = true;
104
visible = false;
105
readOnly = true;
106
description = "function to resolve a module from this aspect";
107
-
type = lib.types.functionTo lib.types.deferredModule;
108
-
default =
109
{
110
class,
111
aspect-chain ? [ ],
112
}:
113
-
resolve class aspect-chain (aspect {
114
inherit class aspect-chain;
115
});
116
};
···
5
aspectsType = lib.types.submodule (
6
{ config, ... }:
7
{
8
+
freeformType = lib.types.attrsOf (lib.types.either aspectSubmoduleAttrs providerType);
9
config._module.args.aspects = config;
10
}
11
);
···
30
);
31
32
functionProviderType = lib.types.either functionToAspect (lib.types.functionTo providerType);
33
+
providerType = lib.types.either functionProviderType aspectSubmodule;
34
35
aspectSubmoduleAttrs = lib.types.addCheck aspectSubmodule (
36
m: (!builtins.isFunction m) || (isAspectSubmoduleFn m)
···
49
(x: lib.length x > 0)
50
];
51
52
+
ignoredType = lib.types.mkOptionType {
53
+
name = "ignored type";
54
+
description = "ignored values";
55
+
merge = _loc: _defs: null;
56
+
check = _: true;
57
+
};
58
+
59
aspectSubmodule = lib.types.submodule (
60
{
61
name,
62
config,
63
...
64
}:
···
84
options.provides = lib.mkOption {
85
description = "Providers of aspect for other aspects";
86
default = { };
87
+
type = lib.types.submodule (
88
+
{ config, ... }:
89
+
{
90
+
freeformType = lib.types.attrsOf providerType;
91
+
config._module.args.aspects = config;
92
+
}
93
+
);
94
};
95
options.__functor = lib.mkOption {
96
internal = true;
···
108
visible = false;
109
readOnly = true;
110
description = "resolved modules from this aspect";
111
+
type = ignoredType;
112
+
apply = _: lib.mapAttrs (class: _: config.resolve { inherit class; }) config;
113
};
114
options.resolve = lib.mkOption {
115
internal = true;
116
visible = false;
117
readOnly = true;
118
description = "function to resolve a module from this aspect";
119
+
type = ignoredType;
120
+
apply =
121
+
_:
122
{
123
class,
124
aspect-chain ? [ ],
125
}:
126
+
resolve class aspect-chain (config {
127
inherit class aspect-chain;
128
});
129
};