Add build watch script

Mainly because emacs blocks while generating the PDF, which is very annoying
This commit is contained in:
Charlotte Van Petegem 2024-01-05 14:57:16 +01:00
parent 931e4252c0
commit 8326dc89da
No known key found for this signature in database
GPG key ID: 019E764B7184435A

View file

@ -127,6 +127,37 @@
help = "build a diffed PDF between latest sent revision and current";
package = build-diffed;
}
{
name = "build";
category = "general commands";
help = "build the PDF";
command = ''
builddir=$(mktemp -d --tmpdir=/tmp)
${emacs}/bin/emacs -batch -load build.el
${full-texlive}/bin/latexmk -f -pdf -lualatex -interaction=nonstopmode -output-directory="''${builddir}" book.tex
mv "''${builddir}"/book.pdf .
rm "''${builddir}" -rf
'';
}
{
name = "watch-build";
category = "general commands";
help = "watch main file and build on change";
command = ''
trap "exit 0" SIGINT SIGTERM
while true
do
time=$(date "+%s")
echo "Waiting for change..."
${pkgs.fswatch}/bin/fswatch -1 book.org >/dev/null
while [ "$time" -lt "$(stat -c %Y book.org)" ]
do
time=$(date "+%s")
build
done
done
'';
}
];
};
packages.build-diffed = build-diffed;