2023-07-23 01:07:20 +00:00
|
|
|
{ self, lib, flake-parts-lib, moduleLocation, ... }:
|
2022-10-16 20:07:14 +00:00
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mapAttrs
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
|
|
|
inherit (flake-parts-lib)
|
|
|
|
mkAliasOptionModule
|
|
|
|
;
|
|
|
|
|
|
|
|
flakeModulesOption = mkOption {
|
|
|
|
type = types.lazyAttrsOf types.deferredModule;
|
|
|
|
default = { };
|
|
|
|
apply = mapAttrs (k: v: {
|
2023-05-09 16:41:01 +00:00
|
|
|
_file = "${toString moduleLocation}#flakeModules.${k}";
|
|
|
|
key = "${toString moduleLocation}#flakeModules.${k}";
|
2022-10-16 20:07:14 +00:00
|
|
|
imports = [ v ];
|
|
|
|
});
|
|
|
|
description = ''
|
|
|
|
flake-parts modules for use by other flakes.
|
|
|
|
|
2023-05-08 15:42:03 +00:00
|
|
|
If the flake defines only one module, it should be `flakeModules.default`.
|
2022-10-16 20:07:14 +00:00
|
|
|
|
2023-05-08 15:42:03 +00:00
|
|
|
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.
|
2022-10-16 20:07:14 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
flake = mkOption {
|
|
|
|
type = types.submoduleWith {
|
|
|
|
modules = [
|
|
|
|
(mkAliasOptionModule [ "flakeModule" ] [ "flakeModules" "default" ])
|
|
|
|
{
|
|
|
|
options.flakeModules = flakeModulesOption;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|