# `mix typsty.packages.get`
[🔗](https://github.com/akoutmos/typsty/blob/0.1.0/lib/mix/tasks/typsty.packages.get.ex#L1)

Downloads [Typst packages](https://typst.app/universe) into your project, so that
templates can import them.

```shell
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`:

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

Templates then import them as usual:

```typst
#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:

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

```shell
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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
