{ pkgs, lib, ... }: rec { /** Convert a Nix document to HTML */ html = document: name: builtins.toFile "${name}.html" '' ${document.title} ${builtins.readFile (commonmark document.body name)} ''; /** Convert a commonmark string to HTML */ commonmark = markdown: name: pkgs.runCommand "${name}.html" { buildInputs = [ pkgs.cmark ]; } '' cmark ${builtins.toFile "${name}.md" markdown} > $out ''; /** Get documents from a flat directory of files */ documents = dir: lib.mapAttrs' ( attrname: value: { name = lib.removeSuffix ".nix" attrname; value = import (dir + "/${attrname}"); } ) (builtins.readDir dir); files = dir: lib.mapAttrs' ( name: document: { name = document.outPath; value = html document "${name}.html"; } ) (documents dir); }