{ pkgs, root }:
pkgs.stdenv.mkDerivation {
name = "grimu-r-website";
src = pkgs.lib.cleanSourceWith {
src = root;
filter = path: type:
let
baseName = baseNameOf path;
relativePath = pkgs.lib.removePrefix (toString root + "/") (toString path);
in
baseName == "README.org" ||
relativePath == "website" ||
pkgs.lib.hasPrefix "website/" relativePath;
};
buildInputs = [ pkgs.pandoc ];
buildPhase = ''
cp $src/website/pandoc-template.html ./
mkdir -p ./html/doc
cp $src/website/favicon.ico ./html/
cp $src/website/llms.txt ./html/
if [ -d "$src/website/doc" ]; then
echo '' >> docs-nav.html
fi
if [ -d "$src/website/doc" ]; then
for file in $src/website/doc/*.org; do
basename=$(basename "$file" .org)
pandoc \
--template=./pandoc-template.html \
--include-before-body=./docs-nav.html \
--shift-heading-level-by=1 \
--section-divs \
-M document-css=false \
"$file" \
-o "./html/doc/$basename.html"
done
fi
pandoc \
--template=./pandoc-template.html \
--shift-heading-level-by=1 \
--section-divs \
-M document-css=false \
$src/README.org \
-o html/index.html
pandoc \
--template=./pandoc-template.html \
--shift-heading-level-by=1 \
--section-divs \
-M document-css=false \
$src/website/pitch.org \
-o html/pitch.html
'';
installPhase = ''
mkdir -p $out/html
mkdir -p $out/bin
cp -r ./html $out/
cat > $out/bin/grimu-r-website <