{config, ...}: { config.flake.flakeModules.default = { lib, flake-parts-lib, ... }: let inherit (lib) attrsToList listToAttrs mkOption types; inherit (flake-parts-lib) mkPerSystemOption; topConfig = config; in { options.perSystem = mkPerSystemOption ({ pkgs, config, ... }: let cfg = config.sloth; sLib = cfg.lib; packageModule = types.submodule ({config, ...}: { options = { module = mkOption { description = "module used to create your neovim package"; type = types.deferredModule; }; modules = mkOption { description = "modules used to create your neovim package"; type = with types; listOf deferredModule; default = [config.module]; }; specialArgs = mkOption { description = "specialArgs to follow to your modules"; type = types.attrs; default = {}; }; }; }); buildPackage = { name, value, }: { inherit name; value = sLib.mkNeovimPkg {inherit (value) modules specialArgs;}; }; packagesList = map buildPackage (attrsToList cfg.packages); in { options.sloth = { lib = mkOption { type = types.attrs; description = "sloth’s lib"; default = topConfig.flake.mkLib {inherit pkgs;}; defaultText = "mkLib {inherit pkgs;}"; }; packages = mkOption { description = "neovim package to create with sloth"; default = {}; type = with types; attrsOf packageModule; }; }; config.packages = listToAttrs packagesList; }); }; }