rules_typst 0.3.0Latest published 1.1mo ago
MODULE.bazel
bazel_dep(name = "rules_typst", version = "0.3.0")
README

rules_typst

Bazel rules for Typst.

Reproducibility

Compilation sees only the declared inputs, so the same sources produce the same PDF bytes on every machine:

  • SOURCE_DATE_EPOCH=0 fixes the document's creation timestamp. Override it through the env attribute to opt out.
  • Fonts installed on the host are ignored. Only the fonts embedded in the pinned compiler are available.
  • The package path and package cache point inside the action, so a @preview import cannot resolve against a developer's ~/.cache/typst.

Fonts are the usual source of "works on my machine": a document that renders with a system font produces a different glyph subset — and therefore different bytes — wherever that font's build differs. Typst reports an unknown font family as a warning and silently falls back to a default, so check the build log if the output is not what you expect.

Hermetic font handling requires Typst 0.12 or newer, when --ignore-system-fonts was added.

Checking in generated PDFs

write_source_file runs diff when its test fails, which prints thousands of lines of xref offsets and compressed font streams for a PDF. Pass --brief so the log reports only that the file changed:

write_source_file(
    name = "write_report_pdf",
    diff_args = ["--brief"],
    diff_test = True,
    in_file = ":report",
    out_file = "generated/report.pdf",
)

Development

Pre-commit hooks

This repo uses pre-commit to run buildifier for formatting and linting Bazel files.

pip install pre-commit
pre-commit install

To manually run against all files:

pre-commit run --all-files

About

Bazel rules for Typst

@periareon/rules_typst@periareon
Homepage
4stars
Wednesday, September 2, 2026
@periareon-bot#10345 rules_typst@0.3.0 (#10345)

Languages

Python12.7%
Rust10.8%
Typst0.6%

Maintainers

@matte1
@abrisco

Versions

0.3.0 +6.0mo2026-09-02
0.2.0 +8h2026-03-05
0.1.02026-03-04