SATySFi
SATySFi copied to clipboard
The ID of the generated PDF changes every time and is not deterministic
It affects Nix, which requires deterministic build.
- https://twitter.com/aumy_f/status/1424958320708706307?s=20
- https://twitter.com/matsud224/status/1425016936748834824?s=20
❯ nix build --rebuild
error: derivation '/nix/store/fmkxj65j1s6iar75c1hm6jm6m201vh4r-pdf.drv' may not be deterministic: output '/nix/store/7i7hclybw9np21j3pl6j6xg1rlz6q13h-pdf' differs
I think SATySFi can have an option to give a random seed to generate reproducible results.
After some searching, I found that upcoming camlpdf 2.5 introduces CAMLPDF_REPRODUCIBLE_IDS
environment variable ^1 which ensures reproducible ids. I think it would be modester to use a method like this rather than fixing a random seed.
I just found it too and was wondering why it does not work in my environment...
Anyway, this issue will be closed when camlpdf is updated to 2.5.
Current code calls the id generating function Pdf.generate_id
via (SATySFi) HandlePdf.write_to_file
→ (CamlPDF) Pdfwrite.pdf_to_file
→ Pdfwrite.pdf_to_file_options
→ Pdfwrite.change_id
→ Pdf.generate_id
.
Pdfwrite.pdf_to_file_options
function does not call Pdfwrite.change_id
if mkid
argument is false
^1. It might be another choice to use Pdfwrite.pdf_to_file_options
with mkid
= false
in HandlePdf.write_to_file
, and attach an ID in SATySFi side.
camlpdf 2.5 has been released, so upgrading it can solve the issue. However, the changelog says that the feature is for testing. Are there any downsides using fixed ID for PDF files? Or should we pass an ID as command-line options or generate it reproducibly on SATySFi side?