{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; inherit (cfg) lib; packageModule = types.submodule { options.modules = mkOption { description = "modules used to create your neovim package"; type = with types; listOf attrs; default = []; }; }; buildPackage = { name, value }: { inherit name; value = (lib.evalSlothModules {inherit (value) modules;}).neovimPackage; }; 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; }); }; }