From 38d43a740f0bee6afb9b781f7301f40fceec0187 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 5 Jul 2024 16:39:32 +0100 Subject: [PATCH] modules/files: don't include modules in the docs This means we no longer need to spoof the module in the docs implementation. Instead, we supply the (optional) special arg `isDocs` to `evalModules`. --- docs/default.nix | 42 +++++++---------------------- docs/mdbook/default.nix | 1 + modules/top-level/files/default.nix | 18 +++++++++++-- 3 files changed, 26 insertions(+), 35 deletions(-) diff --git a/docs/default.nix b/docs/default.nix index 0989b968..e451c6ee 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -56,35 +56,7 @@ let ) opt.declarations; }; - nixvmConfigType = lib.mkOptionType { - name = "nixvim-configuration"; - description = "nixvim configuration options"; - descriptionClass = "noun"; - # Evaluation is irrelevant, only used for documentation. - }; - - # Construct our own top-level modules, because we want to stub the `files` option - # FIXME: add a way to handle this with specialArgs - topLevelModules = [ - ../modules - ../modules/top-level/output.nix - # Fake module to avoid a duplicated documentation - (lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" { - options.files = lib.mkOption { - type = lib.types.attrsOf nixvmConfigType; - description = "Extra files to add to the runtimepath"; - example = { - "ftplugin/nix.lua" = { - options = { - tabstop = 2; - shiftwidth = 2; - expandtab = true; - }; - }; - }; - }; - }) - ]; + modules = [ ../modules/top-level ]; hmOptions = builtins.removeAttrs (lib.evalModules { modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ]; @@ -95,10 +67,11 @@ rec { (pkgsDoc.nixosOptionsDoc { inherit (lib.evalModules { - modules = topLevelModules; + inherit modules; specialArgs = { inherit helpers; defaultPkgs = pkgsDoc; + isDocs = true; }; }) options @@ -112,8 +85,11 @@ rec { # > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535) // lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) { docs = pkgsDoc.callPackage ./mdbook { - inherit transformOptions; - modules = topLevelModules; - inherit helpers hmOptions; + inherit + helpers + modules + hmOptions + transformOptions + ; }; } diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index 8ff49328..649b2994 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -14,6 +14,7 @@ let specialArgs = { inherit helpers; defaultPkgs = pkgs; + isDocs = true; }; }; diff --git a/modules/top-level/files/default.nix b/modules/top-level/files/default.nix index 314be37a..53d3a4b0 100644 --- a/modules/top-level/files/default.nix +++ b/modules/top-level/files/default.nix @@ -3,28 +3,42 @@ config, lib, helpers, + specialArgs, ... }: let inherit (lib) types; + isDocs = specialArgs.isDocs or false; + fileModuleType = types.submoduleWith { shorthandOnlyDefinesConfig = true; specialArgs = { inherit helpers; defaultPkgs = pkgs; }; - modules = [ + # Don't include the modules in the docs, as that'd be redundant + modules = lib.optionals (!isDocs) [ ../../. ./submodule.nix ]; + description = "Nixvim configuration"; }; in { options = { files = lib.mkOption { type = types.attrsOf fileModuleType; - description = "Files to include in the Vim config."; + description = "Extra files to add to the runtimepath"; default = { }; + example = { + "ftplugin/nix.lua" = { + opts = { + tabstop = 2; + shiftwidth = 2; + expandtab = true; + }; + }; + }; }; filesPlugin = lib.mkOption {