Write a Nix expression to compile your document. That way you can be sure it keeps working. I did this long ago for my PhD thesis and other papers.