mix typsty.packages.get (Typsty v0.1.0)

Copy Markdown View Source

Downloads Typst packages into your project, so that templates can import them.

mix typsty.packages.get @preview/cetz:0.4.2 @preview/oxifmt:1.0.0

Packages are saved in priv/typst/packages, laid out as namespace/name/version like Typst's own package directories, so they ship with your releases. Point the :package_paths option at that directory, in config/runtime.exs:

config :typsty, package_paths: [Application.app_dir(:my_app, "priv/typst/packages")]

Templates then import them as usual:

#import "@preview/cetz:0.4.2": canvas, draw

A package given without a version (@preview/cetz) gets its latest version that works with the version of Typst that Typsty uses. Packages that a package imports are fetched too. Packages already in the directory aren't downloaded again, since Typst Universe never changes a published version. Versions you no longer use stay in the directory until you delete them.

Configured packages

Without arguments, the task fetches the packages listed in your config, which keeps the list in your repository and works well in CI and Docker builds:

# config/config.exs
config :typsty, packages: ["@preview/cetz:0.4.2", "@preview/oxifmt:1.0.0"]
mix typsty.packages.get

Packages in the config must have a version, since templates import exact versions: an unpinned package would change whenever a new version came out. In a Docker build, run the task in the build stage, before mix release; it needs the network.

Options

  • --path - the directory to save packages in. Defaults to priv/typst/packages, in the current project. In an umbrella project, run the task in the app that renders, or give a path.
  • --force - download packages again, even if they're already in the directory.

Downloads go through the proxy in HTTPS_PROXY (or HTTP_PROXY) when one is set, except for the hosts in NO_PROXY. The proxy must be an HTTP one (http://, which can still forward HTTPS): the task can't talk to proxies over HTTPS or SOCKS, and refuses them rather than send them a password in the clear or go around them.