Add build and build-adoc scripts
All checks were successful
/ check (push) Successful in 1m51s

This commit is contained in:
Oliver Davies 2025-09-04 21:02:57 +01:00
parent 1936fadea5
commit 75ebf874f0
2 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,62 @@
{
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
'';
})
];
};
}

16
modules/scripts/build.nix Normal file
View file

@ -0,0 +1,16 @@
{
flake.modules.homeManager.base =
{ pkgs, ... }:
{
home.packages = [
(pkgs.writeShellApplication {
name = "build";
text = ''
test -r book/index.adoc && exec build-adoc "$@"
test -x build && exec ./build "$@"
'';
})
];
};
}