From 417176c4fc60a5f0051057cd6dc6446fdff29ab8 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Mon, 22 Dec 2025 07:51:55 +0000 Subject: [PATCH] nix: add derivation to build docs site Change-Id: pwlpxlzvwrmotnuytqrxqxoxrrrrpvts using pandoc, tailwindcss, our standard fonts and lucide, we can build a simple docs site with a single pandoc command. Signed-off-by: oppiliappan --- flake.nix | 7 +++++-- nix/pkgs/docs.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 nix/pkgs/docs.nix diff --git a/flake.nix b/flake.nix index 56374105..cc382c0b 100644 --- a/flake.nix +++ b/flake.nix @@ -88,13 +88,16 @@ inherit htmx-src htmx-ws-src lucide-src inter-fonts-src ibm-plex-mono-src actor-typeahead-src; }; appview = self.callPackage ./nix/pkgs/appview.nix {}; + docs = self.callPackage ./nix/pkgs/docs.nix { + inherit inter-fonts-src ibm-plex-mono-src lucide-src; + }; spindle = self.callPackage ./nix/pkgs/spindle.nix {}; knot-unwrapped = self.callPackage ./nix/pkgs/knot-unwrapped.nix {}; knot = self.callPackage ./nix/pkgs/knot.nix {}; }); in { overlays.default = final: prev: { - inherit (mkPackageSet final) lexgen goat sqlite-lib spindle knot-unwrapped knot appview; + inherit (mkPackageSet final) lexgen goat sqlite-lib spindle knot-unwrapped knot appview docs; }; packages = forAllSystems (system: let @@ -103,7 +106,7 @@ staticPackages = mkPackageSet pkgs.pkgsStatic; crossPackages = mkPackageSet pkgs.pkgsCross.gnu64.pkgsStatic; in { - inherit (packages) appview appview-static-files lexgen goat spindle knot knot-unwrapped sqlite-lib; + inherit (packages) appview appview-static-files lexgen goat spindle knot knot-unwrapped sqlite-lib docs; pkgsStatic-appview = staticPackages.appview; pkgsStatic-knot = staticPackages.knot; diff --git a/nix/pkgs/docs.nix b/nix/pkgs/docs.nix new file mode 100644 index 00000000..c9a58718 --- /dev/null +++ b/nix/pkgs/docs.nix @@ -0,0 +1,41 @@ +{ + pandoc, + tailwindcss, + runCommandLocal, + inter-fonts-src, + ibm-plex-mono-src, + lucide-src, + src, +}: +runCommandLocal "docs" {} '' + mkdir -p working + + # copy templates, themes, styles, filters to working directory + cp ${src}/docs/*.html working/ + cp ${src}/docs/*.theme working/ + cp ${src}/docs/*.css working/ + + # icons + cp -rf ${lucide-src}/*.svg working/ + + # content + ${pandoc}/bin/pandoc ${src}/docs/DOCS.md \ + -o $out/ \ + -t chunkedhtml \ + --variable toc \ + --toc-depth=2 \ + --css=stylesheet.css \ + --chunk-template="%i.html" \ + --highlight-style=working/highlight.theme \ + --template=working/template.html + + # fonts + mkdir -p $out/static/fonts + cp -f ${inter-fonts-src}/web/InterVariable*.woff2 $out/static/fonts/ + cp -f ${inter-fonts-src}/web/InterDisplay*.woff2 $out/static/fonts/ + cp -f ${inter-fonts-src}/InterVariable*.ttf $out/static/fonts/ + cp -f ${ibm-plex-mono-src}/fonts/complete/woff2/IBMPlexMono*.woff2 $out/static/fonts/ + + # styles + cd ${src} && ${tailwindcss}/bin/tailwindcss -i input.css -o $out/stylesheet.css +'' -- 2.43.0