mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-29 17:33:46 +03:00
36 lines
889 B
Nix
36 lines
889 B
Nix
{config, lib, ...}: let
|
|
|
|
modulesDir = ../.;
|
|
|
|
moduleKinds = builtins.readDir modulesDir;
|
|
|
|
mapModules = kind:
|
|
lib.mapAttrs'
|
|
(fn: _:
|
|
lib.nameValuePair
|
|
(lib.removeSuffix ".nix" fn)
|
|
(modulesDir + "/${kind}/${fn}"))
|
|
(builtins.readDir (modulesDir + "/${kind}"));
|
|
|
|
flakePartsModules = lib.attrValues (
|
|
lib.filterAttrs
|
|
(modName: _: modName != "all-modules")
|
|
(mapModules "flake-parts")
|
|
);
|
|
|
|
in {
|
|
|
|
imports = flakePartsModules;
|
|
|
|
options.flake.modules = lib.mkOption {
|
|
type = lib.types.anything;
|
|
};
|
|
|
|
# generates future flake outputs: `modules.<kind>.<module-name>`
|
|
config.flake.modules = lib.mapAttrs (kind: _: mapModules kind) moduleKinds;
|
|
|
|
# comapt to current schema: `nixosModules` / `darwinModules`
|
|
config.flake.nixosModules = config.flake.modules.nixos or {};
|
|
config.flake.darwinModules = config.flake.modules.darwin or {};
|
|
}
|