nvf/docs/manual.nix

69 lines
1.6 KiB
Nix
Raw Permalink Normal View History

2023-12-09 19:03:58 +00:00
{
lib,
2024-04-18 18:07:19 +00:00
stdenvNoCC,
# build inputs
nixos-render-docs,
2023-12-09 19:03:58 +00:00
documentation-highlighter,
2024-04-18 18:07:19 +00:00
# nrd configuration
manpageUrls,
2023-12-09 19:03:58 +00:00
revision,
options,
2024-04-18 18:07:19 +00:00
outputPath ? "share/doc/neovim-flake",
2023-12-09 19:03:58 +00:00
}:
2024-04-18 18:07:19 +00:00
stdenvNoCC.mkDerivation {
2023-12-09 19:03:58 +00:00
name = "neovim-flake-manual";
2024-04-20 03:57:11 +00:00
src = builtins.path {
2024-04-18 18:07:19 +00:00
path = lib.sourceFilesBySuffices ./manual [".md"];
2024-04-20 03:57:11 +00:00
name = "neovim-flake-manual";
};
2023-12-09 19:03:58 +00:00
nativeBuildInputs = [nixos-render-docs];
buildPhase = ''
2024-04-20 03:57:11 +00:00
mkdir -p out/{highlightjs,media}
2023-12-09 19:03:58 +00:00
2024-04-20 03:57:11 +00:00
cp -vt out/highlightjs \
2023-12-09 19:03:58 +00:00
${documentation-highlighter}/highlight.pack.js \
${documentation-highlighter}/LICENSE \
${documentation-highlighter}/mono-blue.css \
${documentation-highlighter}/loader.js
substituteInPlace ./options.md \
--subst-var-by \
OPTIONS_JSON \
2023-12-09 19:03:58 +00:00
${options.neovim-flake}/share/doc/nixos/options.json
substituteInPlace ./manual.md \
--subst-var-by \
NVF_VERSION \
2023-12-09 19:03:58 +00:00
${revision}
# copy stylesheet
cp ${./static/style.css} out/style.css
2024-04-20 03:57:11 +00:00
# copy release notes
cp -vr ${./release-notes} release-notes
2023-12-09 19:03:58 +00:00
2024-04-20 03:57:11 +00:00
# generate manual from
2023-12-09 19:03:58 +00:00
nixos-render-docs manual html \
2024-04-18 18:07:19 +00:00
--manpage-urls ${manpageUrls} \
2023-12-09 19:03:58 +00:00
--revision ${lib.trivial.revisionWithDefault revision} \
--stylesheet style.css \
2024-04-20 03:57:11 +00:00
--script highlightjs/highlight.pack.js \
--script highlightjs/loader.js \
--toc-depth 2 \
2024-04-20 03:58:39 +00:00
--section-toc-depth 1 \
2023-12-09 19:03:58 +00:00
manual.md \
out/index.xhtml
'';
installPhase = ''
dest="$out/${outputPath}"
mkdir -p "$(dirname "$dest")"
mv out "$dest"
mkdir -p $out/nix-support/
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products
'';
}