tomato·bazeldocs v0 · latest
Docs/Reference/Modules/rules_tectonic

rules_tectonic

Bazel rules to compile LaTeX into PDFs via tectonic.

Latest0.2.0
Versions3
CategoryBazel rules
Compat level1
MaintainersMatt Marshall
Registryhttps://registry.tbzl.dev/modules/rules_tectonic/
Sourcegithub.com/tomato-bazel/rules_tectonic
MODULE.bazelstarlark
bazel_dep(name = "rules_tectonic", version = "0.2.0")

View source & releases on GitHub ↗

Bazel rules to compile LaTeX → PDF using tectonic, the modern, self-bootstrapping TeX engine. Prebuilt release binaries are fetched per host platform via rules_github; no system LaTeX install required.

Install

Add the fastverk registry to your .bazelrc:

common --registry=https://registry.fastverk.com/
common --registry=https://bcr.bazel.build/

In your MODULE.bazel:

bazel_dep(name = "rules_tectonic", version = "0.1.0")

tectonic = use_extension("@rules_tectonic//tectonic:extensions.bzl", "tectonic")
use_repo(tectonic, "tectonic")
register_toolchains("@tectonic//:tectonic_toolchain_def")

Quick start

load("@rules_tectonic//tectonic:defs.bzl", "tectonic_pdf")

tectonic_pdf(
    name = "paper",
    main = "main.tex",
    srcs = [
        "arxiv.sty",
        "figs/loss_curve.png",
        "refs.bib",
    ],
)

bazel build //paper:paper writes paper.pdf into bazel-bin.

Pinning a non-default version

tectonic = use_extension("@rules_tectonic//tectonic:extensions.bzl", "tectonic")
tectonic.toolchain(version = "0.15.0")
use_repo(tectonic, "tectonic")

The pinned version must have its per-platform sha256s recorded in tectonic/private/known_versions.bzl. PRs welcome to add newer releases.

Supported platforms

Canonical idUpstream target triple
darwin_aarch64aarch64-apple-darwin
darwin_x86_64x86_64-apple-darwin
linux_aarch64aarch64-unknown-linux-musl
linux_x86_64x86_64-unknown-linux-musl

Windows is not currently supported by this module; PRs welcome.

Notes on hermeticity

Tectonic’s first build per Bazel output_base fetches font + class files from the tectonic bundle CDN (note: downloading cmr10.pfb…). These are cached at ~/.cache/Tectonic/; subsequent builds are fully offline. The action runs with use_default_shell_env = True so the cache is reused across invocations.

For strict-hermetic builds, pre-fetch the bundle as a http_archive and pass --web-bundle=file://... to tectonic. Not currently exposed; file an issue if needed.

License

Apache-2.0.

Usage#

Real usage, taken from the module’s examples/.

examples/BUILD.bazel

load("@rules_tectonic//tectonic:defs.bzl", "tectonic_pdf")

# `bazel build //examples:smoke` from this repo's checkout proves the
# rule wires up end-to-end. Consumers don't need this target.
tectonic_pdf(
    name = "smoke",
    main = "smoke.tex",
)

examples/sectioned/BUILD.bazel

load(
    "@rules_tectonic//tectonic:defs.bzl",
    "tex_paper",
    "tex_section",
)

# Smoke test for the v0.0.2 `tex_section` + `tex_paper` rules.
# Two sections in their own files, composed into a single PDF.
#
#   bazel build //examples/sectioned:sectioned_paper
#
# produces `sectioned_paper.pdf`.

tex_section(
    name = "intro",
    src = "intro.tex",
    section_label = "sec:intro",
)

tex_section(
    name = "body",
    src = "body.tex",
    section_label = "sec:body",
)

tex_paper(
    name = "sectioned_paper",
    preamble = "preamble.tex",
    sections = [
        ":intro",
        ":body",
    ],
)

Conformance#

No gate findings. 8 contested atoms. See how gating works or the full report.

Contested atoms

Third-party modules where this module resolves a different version than others do. Not a violation of anything this module did — it is the actionable form of a registry-level convergence finding, and the sentence a maintainer can act on.

AtomResolved hereElsewhere
apple_support 1.24.2 2.2.0 ×1
bazel_skylib 1.8.2 1.9.0 ×2
nlohmann_json 3.6.1 3.12.0.bcr.1 ×1
protobuf 33.4 34.0.bcr.1 ×2
rules_jvm_external 6.7 6.8 ×4
rules_python 1.7.0 2.0.1 ×1
rules_swift 3.1.2 3.6.1 ×1
upb 0.0.0-20220923-a547704 0.0.0-20230516-61a97ef ×1

Dependencies#

rules_tectonic in the registry graph — what it depends on (left) and what depends on it (right).

Depends on

platforms0.0.10bazel_skylib1.7.1rules_github0.1.1

Used by (5 in the registry)

Versions#

3 published versions, newest first. Each resolves to an immutable, integrity-checked archive.

VersionIntegrity (sha256)Source archive
0.2.0 latest 3InU+ILCoRB164cb… tag archive ↗
0.1.1 d3eHtj3llOrSONVu… tag archive ↗
0.1.0 Js6+Dem19F+c9AAn… tag archive ↗

Changelog#

All notable changes to this module are documented here; this project adheres to Keep a Changelog and SemVer.

[Unreleased]

← All modules