diff --git a/docs/manual.nix b/docs/manual.nix index f5b23d04..b9f9888b 100644 --- a/docs/manual.nix +++ b/docs/manual.nix @@ -8,56 +8,78 @@ # nrd configuration release, optionsJSON, -}: -stdenvNoCC.mkDerivation { - name = "nvf-manual"; - src = builtins.path { - path = lib.sourceFilesBySuffices ./manual [".md"]; +} @ args: let + manual-release = args.release or "unstable"; +in + stdenvNoCC.mkDerivation { name = "nvf-manual"; - }; + src = builtins.path { + name = "nvf-manual-${manual-release}"; + path = lib.sourceFilesBySuffices ./manual [".md" ".md.in"]; + }; - nativeBuildInputs = [nixos-render-docs]; + nativeBuildInputs = [nixos-render-docs]; - buildPhase = '' - dest="$out/share/doc/nvf" - mkdir -p "$(dirname "$dest")" - mkdir -p $dest/{highlightjs,media} + postPatch = '' + ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json + ''; - cp -vt $dest/highlightjs \ - ${documentation-highlighter}/highlight.pack.js \ - ${documentation-highlighter}/LICENSE \ - ${documentation-highlighter}/mono-blue.css \ - ${documentation-highlighter}/loader.js + buildPhase = '' + dest="$out/share/doc/nvf" + mkdir -p "$(dirname "$dest")" + mkdir -p $dest/{highlightjs,script} - substituteInPlace ./options.md \ - --subst-var-by \ - OPTIONS_JSON \ - ${optionsJSON}/share/doc/nixos/options.json + # Copy highlight scripts to /highlights in document root. + cp -vt $dest/highlightjs \ + ${documentation-highlighter}/highlight.pack.js \ + ${documentation-highlighter}/LICENSE \ + ${documentation-highlighter}/mono-blue.css \ + ${documentation-highlighter}/loader.js - substituteInPlace ./manual.md \ - --subst-var-by \ - NVF_VERSION \ - ${release} + cp -vt $dest/script \ + ${./static/script}/anchor-min.js \ + ${./static/script}/anchor-use.js - # copy stylesheet - cp ${./static/style.css} "$dest/style.css" + substituteInPlace ./options.md \ + --subst-var-by OPTIONS_JSON ./config-options.json - # copy release notes - cp -vr ${./release-notes} release-notes + substituteInPlace ./manual.md \ + --subst-var-by NVF_VERSION ${manual-release} \ + --subst-var-by NVF_SRC "https://github.com/nvf/blob/${manual-release}" - # generate manual from - nixos-render-docs manual html \ - --manpage-urls ${path + "/doc/manpage-urls.json"} \ - --revision ${lib.trivial.revisionWithDefault release} \ - --stylesheet style.css \ - --script highlightjs/highlight.pack.js \ - --script highlightjs/loader.js \ - --toc-depth 2 \ - --section-toc-depth 1 \ - manual.md \ - "$dest/index.xhtml" + # copy stylesheet + cp ${./static/style.css} "$dest/style.css" - mkdir -p $out/nix-support/ - echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products - ''; -} + + # copy release notes + cp -vr ${./release-notes} release-notes + + # Generate final manual from a set of parameters. Explanation of the CLI flags are + # as follows: + # + # 1. --manpage-urls will allow you to use manual pages as they are defined in + # the nixpkgs documentation. + # 2. --revision is the project revision as it is defined in 'release.json' in the + # repository root + # 3. --script will inject a given Javascript file into the resulting pages inside + # the