-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathflakeModules.nix
47 lines (43 loc) · 1.24 KB
/
flakeModules.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{ self, lib, flake-parts-lib, moduleLocation, ... }:
let
inherit (lib)
mapAttrs
mkOption
types
;
inherit (flake-parts-lib)
mkAliasOptionModule
;
flakeModulesOption = mkOption {
type = types.lazyAttrsOf types.deferredModule;
default = { };
apply = mapAttrs (k: v: {
_file = "${toString moduleLocation}#flakeModules.${k}";
key = "${toString moduleLocation}#flakeModules.${k}";
imports = [ v ];
_class = "flake";
});
description = ''
flake-parts modules for use by other flakes.
If the flake defines only one module, it should be `flakeModules.default`.
You can not read this option in defining the flake's own `imports`. Instead, you can
put the module in question into its own file or let binding and reference
it both in `imports` and export it with this option.
See [Dogfood a Reusable Module](../dogfood-a-reusable-module.md) for details and an example.
'';
};
in
{
options = {
flake = mkOption {
type = types.submoduleWith {
modules = [
(mkAliasOptionModule [ "flakeModule" ] [ "flakeModules" "default" ])
{
options.flakeModules = flakeModulesOption;
}
];
};
};
};
}