diff --git a/docs/default.nix b/docs/default.nix new file mode 100644 index 00000000..422948f5 --- /dev/null +++ b/docs/default.nix @@ -0,0 +1,143 @@ +{ pkgs ? import { overlays = [ (import ../overlays).default ]; } }: + +let + inherit (pkgs) lib nixosOptionsDoc; + + mkOptionsDoc = args@{ class, modules, includeModuleSystemArguments ? false, ... }: + let + modulesEval = + if class == "nixos" + then lib.evalModules { + modules = modules ++ lib.singleton { + imports = [ + "${pkgs.path}/nixos/modules/misc/extra-arguments.nix" + + # One of the modules requires this to be included. + "${pkgs.path}/nixos/modules/config/xdg/mime.nix" + ]; + _module.check = false; + _module.args.pkgs = pkgs; + fileSystems."/".device = "nodev"; + }; + } + else if class == "homeManager" + then + let + hmLib = import lib; + in + lib.evalModules { + modules = modules ++ lib.singleton { + _module.check = false; + _module.args.pkgs = pkgs; + lib = hmLib.hm; + }; + } + else if class == "wrapperManager" then + let + wrapper-manager = import ../subprojects/wrapper-manager-fds { }; + in + wrapper-manager.lib.eval { + inherit pkgs; + modules = modules ++ lib.singleton { + _module.check = false; + }; + } + else + lib.evalModules { + modules = modules ++ lib.singleton { + _module.check = false; + _module.args.pkgs = pkgs; + }; + }; + + inherit (modulesEval) options; + in + nixosOptionsDoc ({ + options = + if includeModuleSystemArguments + then options + else builtins.removeAttrs options [ "_module" ]; + } + // builtins.removeAttrs args [ "modules" "class" "includeModuleSystemArguments" ]); + + mkManpage = { optionsJSON, asciidocHeader }: + pkgs.runCommand "wrapper-manager-reference-manpage" + { + nativeBuildInputs = with pkgs; [ + nixos-render-docs + asciidoctor + ]; + } + '' + mkdir -p $out/share/man/man5 + asciidoctor --attribute is-wider-scoped --backend manpage \ + ${asciidocHeader} --out-file header.5 + nixos-render-docs options manpage --revision ${pkgs.lib.version} \ + --header ./header.5 --footer ${./manpages/footer.5} \ + ${optionsJSON}/share/doc/nixos/options.json \ + $out/share/man/man5/wrapper-manager.nix.5 + ''; +in +{ + nixos = rec { + optionsDoc = mkOptionsDoc { + modules = [ ../modules/nixos ../modules/nixos/_private ]; + class = "nixos"; + }; + + outputs.manpage = mkManpage { + inherit (optionsDoc) optionsJSON; + asciidocHeader = ./manpages/nixos-header.adoc; + }; + }; + + home-manager = rec { + optionsDoc = mkOptionsDoc { + modules = [ ../modules/home-manager ../modules/home-manager/_private ]; + class = "homeManager"; + }; + + outputs.manpage = mkManpage { + inherit (optionsDoc) optionsJSON; + asciidocHeader = ./manpages/home-manager-header.adoc; + }; + }; + + nixvim = rec { + optionsDoc = mkOptionsDoc { + modules = [ ../modules/nixvim ../modules/nixvim/_private ]; + class = "nixvim"; + }; + + outputs.manpage = mkManpage { + inherit (optionsDoc) optionsJSON; + asciidocHeader = ./manpages/nixvim-header.adoc; + }; + }; + + wrapper-manager = rec { + optionsDoc = mkOptionsDoc { + modules = [ ../modules/wrapper-manager ../modules/wrapper-manager/_private ]; + class = "wrapperManager"; + }; + + outputs.manpage = mkManpage { + inherit (optionsDoc) optionsJSON; + asciidocHeader = ./manpages/wrapper-manager-header.adoc; + }; + }; + + flake-parts = rec { + optionsDoc = mkOptionsDoc { + modules = [ ../modules/flake-parts ]; + class = "flakeParts"; + }; + + outputs.manpage = mkManpage { + inherit (optionsDoc) optionsJSON; + asciidocHeader = ./manpages/flake-parts-header.adoc; + }; + }; + + website = pkgs.callPackage ./website/package.nix { }; +} diff --git a/docs/manpages/footer.5 b/docs/manpages/footer.5 new file mode 100644 index 00000000..fe3169d5 --- /dev/null +++ b/docs/manpages/footer.5 @@ -0,0 +1,3 @@ +.SH "AUTHORS" +.PP +foodogsquared diff --git a/docs/manpages/wrapper-manager-header.adoc b/docs/manpages/wrapper-manager-header.adoc new file mode 100644 index 00000000..b70ee48e --- /dev/null +++ b/docs/manpages/wrapper-manager-header.adoc @@ -0,0 +1,11 @@ += foodogsquared-wrapper-manager-extra-modules(5) +:doctype: manpage +:manmanual: foodogsquared's wrapper-manager extra module +:mansource: foodogsquared's wrapper-manager extra module + + +== Name + +wrapper-manager-foodogsquared-modules.nix - foodogsquared's extra *wrapper-manager.nix(5)* modules + +== Options