diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index b92df25b..d47aeece 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -67,17 +67,18 @@ let filterAttrs (_: component: component.isOption && (isVisible component)) opts; path = removeWhitespace (concatStringsSep "/" path); moduleDoc = - if builtins.length path >= 2 && lib.hasAttrByPath path nixvimInfo then - let - info = lib.getAttrFromPath path nixvimInfo; - maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]); - maintainersNames = builtins.map (m: m.name) maintainers; - in + let + info = optionalAttrs (hasAttrByPath path nixvimInfo) (getAttrFromPath path nixvimInfo); + maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]); + maintainersNames = builtins.map (m: m.name) maintainers; + in + # Make sure this path has a valid info attrset + if info ? file && info ? description && info ? url then "# ${lib.last path}\n\n" + (lib.optionalString (info.description != null) "${info.description}\n\n") + (lib.optionalString (info.url != null) "**Url:** [${info.url}](${info.url})\n\n") + (lib.optionalString ( - builtins.length maintainers > 0 + maintainers != [ ] ) "**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n") else null; diff --git a/flake-modules/modules.nix b/flake-modules/modules.nix index 81eb473f..a92687c9 100644 --- a/flake-modules/modules.nix +++ b/flake-modules/modules.nix @@ -26,20 +26,17 @@ with lib; { # Attribute may contain the following fields: - # - name: Name of the module - # - kind: Either colorschemes or plugins + # - path: Path to the module, e.g. [ "plugins" "" ] # - description: A short description of the plugin # - url: Url for the plugin # - # [kind name] will identify the plugin - # # We need to use an attrs instead of a submodule to handle the merge. options.meta.nixvimInfo = mkOption { type = (types.nullOr types.attrs) // { # This will create an attrset of the form: - # { - # "path"."to"."plugin" = { "" = ; }; - # } + # + # { path.to.plugin.name = ; } + # # # Where is an attrset of the form: # { @@ -52,12 +49,13 @@ lib.foldl' ( acc: def: - lib.recursiveUpdate acc { - "${def.value.kind}"."${def.value.name}" = { - inherit (def.value) url description; + lib.recursiveUpdate acc ( + setAttrByPath def.value.path { inherit (def) file; - }; - } + url = def.value.url or null; + description = def.value.description or null; + } + ) ) { plugins = { }; diff --git a/lib/neovim-plugin.nix b/lib/neovim-plugin.nix index cdb76119..a0837c95 100644 --- a/lib/neovim-plugin.nix +++ b/lib/neovim-plugin.nix @@ -65,8 +65,11 @@ rec { meta = { inherit maintainers; nixvimInfo = { - inherit description name url; - kind = namespace; + inherit description url; + path = [ + namespace + name + ]; }; }; diff --git a/lib/vim-plugin.nix b/lib/vim-plugin.nix index 3b891213..1761ed15 100644 --- a/lib/vim-plugin.nix +++ b/lib/vim-plugin.nix @@ -68,8 +68,11 @@ with lib; meta = { inherit maintainers; nixvimInfo = { - inherit description name url; - kind = namespace; + inherit description url; + path = [ + namespace + name + ]; }; }; options.${namespace}.${name} = {