nix-config/modules/scripts/build-adoc.nix
Oliver Davies 75ebf874f0
All checks were successful
/ check (push) Successful in 1m51s
Add build and build-adoc scripts
2025-09-04 21:16:52 +01:00

62 lines
1.4 KiB
Nix

{
flake.modules.homeManager.base =
{ pkgs, ... }:
{
home.packages = [
(pkgs.writeShellApplication {
name = "build-adoc";
runtimeInputs = with pkgs; [
asciidoctor-with-extensions
];
excludeShellChecks = [ "SC2034" ];
text = ''
ls book
echo ""
date=$(date '+%Y-%m-%d %H:%M:%S')
echo "The current date is $date."
pwd=$(pwd)
parent=$(basename "$(dirname "$pwd")")
name=$(basename "$pwd")
echo "The parent directory is $parent."
echo "The current directory is $name."
echo ""
echo "Generating the HTML..."
asciidoctor \
-D book \
-a "date=$date" \
-o index.html \
./book/index.adoc
echo ""
echo "Generating the EPUB..."
asciidoctor-epub3 \
-D book \
-a "date=$date" \
-o "$parent-$name.epub" \
./book/index.adoc
echo ""
echo "Generating the PDF..."
asciidoctor-pdf \
-D book \
-a "date=$date" \
-o "$parent-$name.pdf" \
./book/index.adoc
echo ""
ls book
'';
})
];
};
}