From aad1b16e7b44c70b1233dc1ac47f8d43dd906940 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 24 Sep 2025 12:28:40 +0300 Subject: [PATCH 01/18] flake: add ndg as an input Signed-off-by: NotAShelf Change-Id: I6a6a6964151352d958f0c64949769d98dd759bdc --- flake.lock | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 3 ++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index 9e8b3eb5..20d64cb6 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,21 @@ "url": "https://git.lix.systems/lix-project/flake-compat.git" } }, + "flake-compat_2": { + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -36,6 +51,24 @@ "type": "github" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1756770412, + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "4524271976b625a4a605beefd893f270620fd751", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "mnw": { "locked": { "lastModified": 1758834834, @@ -51,7 +84,58 @@ "type": "github" } }, + "ndg": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1758451644, + "narHash": "sha256-sP4hBXifUIrEk37N+NRp3p42Os4OahX/8w1CN74nig8=", + "owner": "feel-co", + "repo": "ndg", + "rev": "a7c8f6ca855335c4dff4826a0245ee93e1816b70", + "type": "github" + }, + "original": { + "owner": "feel-co", + "repo": "ndg", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1764081664, + "narHash": "sha256-sUoHmPr/EwXzRMpv1u/kH+dXuvJEyyF2Q7muE+t0EU4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c23193b943c6c689d70ee98ce3128239ed9e32d1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1754788789, + "narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "a73b9c743612e4244d865a2fdee11865283c04e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1764081664, "narHash": "sha256-sUoHmPr/EwXzRMpv1u/kH+dXuvJEyyF2Q7muE+t0EU4=", @@ -72,7 +156,8 @@ "flake-compat": "flake-compat", "flake-parts": "flake-parts", "mnw": "mnw", - "nixpkgs": "nixpkgs", + "ndg": "ndg", + "nixpkgs": "nixpkgs_2", "systems": "systems" } }, diff --git a/flake.nix b/flake.nix index 35820e0b..31e8d0f1 100644 --- a/flake.nix +++ b/flake.nix @@ -105,5 +105,8 @@ # Alternate neovim-wrapper mnw.url = "github:Gerg-L/mnw"; + + # Alternative documentation generator + ndg.url = "github:feel-co/ndg"; }; } From 868c7c51b4f7b093438fa373f8e4ec0d813955de Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 26 Sep 2025 15:04:21 +0300 Subject: [PATCH 02/18] docs: adapt builder functions for ndg Signed-off-by: NotAShelf Change-Id: I6a6a6964720fae8f3db129835efa5d5df956c3ef --- docs/default.nix | 2 +- docs/manual.nix | 182 ++++++++++++++++++++++++----------------------- 2 files changed, 94 insertions(+), 90 deletions(-) diff --git a/docs/default.nix b/docs/default.nix index 49f90b80..662dd403 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -92,7 +92,7 @@ # Generate the HTML manual pages html = pkgs.callPackage ./manual.nix { - inherit release; + inherit inputs release; inherit (nvimModuleDocs) optionsJSON; }; in { diff --git a/docs/manual.nix b/docs/manual.nix index 50a5dab4..1ce89126 100644 --- a/docs/manual.nix +++ b/docs/manual.nix @@ -1,114 +1,118 @@ { - lib, + inputs, stdenvNoCC, - fetchzip, runCommandLocal, # build inputs - nixos-render-docs, - documentation-highlighter, - dart-sass, path, # nrd configuration release, optionsJSON, } @ args: let manual-release = args.release or "unstable"; +in + runCommandLocal "hjem-docs" { + nativeBuildInputs = [inputs.ndg.packages.${stdenvNoCC.system}.ndg]; + } '' + mkdir -p $out/share/doc - scss-reset = fetchzip { - url = "https://github.com/Frontend-Layers/scss-reset/archive/refs/tags/1.4.2.zip"; - hash = "sha256-cif5Sx8Ca5vxdw/mNAgpulLH15TwmzyJFNM7JURpoaE="; + # Copy the markdown sources to be processed by ndg + cp -rvf ${./manual} ./manual + + substituteInPlace ./manual/options.md \ + --subst-var-by OPTIONS_JSON ./config-options.json + + substituteInPlace ./manual/index.md \ + --subst-var-by NVF_VERSION ${manual-release} + + substituteInPlace ./manual/hacking/additional-plugins.md \ + --subst-var-by NVF_REPO "https://github.com/notashelf/nvf/blob/${manual-release}" + + ndg html \ + --jobs $NIX_BUILD_CORES --title "NVF" \ + --module-options ${optionsJSON}/share/doc/nixos/options.json \ + --manpage-urls ${path}/doc/manpage-urls.json \ + --options-depth 3 \ + --generate-search true \ + --highlight-code true \ + --input-dir ./manual \ + --output-dir "$out/share/doc" + + # Hydra support. Probably not necessary. + mkdir -p $out/nix-support/ + echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products + '' +/* +stdenvNoCC.mkDerivation { + name = "nvf-manual"; + src = builtins.path { + name = "nvf-manual-${manual-release}"; + path = lib.sourceFilesBySuffices ./manual [".md" ".md.in"]; }; - compileStylesheet = runCommandLocal "compile-nvf-stylesheet" {} '' - mkdir -p $out + strictDependencies = true; + nativeBuildInputs = [nixos-render-docs]; - tmpfile=$(mktemp -d) - trap "rm -r $tmpfile" EXIT - - ln -s "${scss-reset}/build" "$tmpfile/scss-reset" - - ${dart-sass}/bin/sass --load-path "$tmpfile" \ - ${./static/style.scss} "$out/style.css" - - echo "Generated styles" + postPatch = '' + ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json ''; -in - stdenvNoCC.mkDerivation { - name = "nvf-manual"; - src = builtins.path { - name = "nvf-manual-${manual-release}"; - path = lib.sourceFilesBySuffices ./manual [".md" ".md.in"]; - }; - strictDependencies = true; - nativeBuildInputs = [nixos-render-docs]; + buildPhase = '' + dest="$out/share/doc/nvf" + mkdir -p "$(dirname "$dest")" + mkdir -p $dest/{highlightjs,script} - postPatch = '' - ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-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 - buildPhase = '' - dest="$out/share/doc/nvf" - mkdir -p "$(dirname "$dest")" - mkdir -p $dest/{highlightjs,script} + # Copy anchor scripts to the script directory in document root. + cp -vt "$dest"/script \ + ${./static/script}/anchor-min.js \ + ${./static/script}/anchor-use.js \ + ${./static/script}/search.js - # 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 - # Copy anchor scripts to the script directory in document root. - cp -vt "$dest"/script \ - ${./static/script}/anchor-min.js \ - ${./static/script}/anchor-use.js \ - ${./static/script}/search.js - substituteInPlace ./options.md \ - --subst-var-by OPTIONS_JSON ./config-options.json + # Move compiled stylesheet + cp -vt $dest \ + ${compileStylesheet}/style.css - substituteInPlace ./manual.md \ - --subst-var-by NVF_VERSION ${manual-release} + # Move release notes + cp -vr ${./release-notes} release-notes - substituteInPlace ./hacking/additional-plugins.md \ - --subst-var-by NVF_REPO "https://github.com/notashelf/nvf/blob/${manual-release}" + # 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