# `mix nbpr.fetch`
[🔗](https://github.com/jimsynz/nbpr/blob/v0.2.0/lib/mix/tasks/nbpr.fetch.ex#L1)

Walks the user's loaded applications for nbpr packages, fetches each one's
artefact tarball for the active Nerves system (if not already cached), and
copies the artefact's `target/` contents into the package's `priv/` so it
ships as part of the OTP release.

    mix nbpr.fetch

Intended to run before `mix firmware`. Recommended wiring:

    aliases: ["firmware": ["nbpr.fetch", "firmware"]]

## Discovery

An nbpr package is detected by:

1. Its application name starts with `nbpr_`.
2. The corresponding `NBPR.<Camel>` module exports `__nbpr_package__/0`.

## Required environment

Must be run with `MIX_TARGET` set to a real Nerves target — there's no
work to do for `:host`. The active Nerves system and version are read
from `Nerves.Env.system/0`.

## See also

The wider rationale for staging into `priv/` (rather than a rootfs overlay)
and the runtime `PATH`/`LD_LIBRARY_PATH` setup is in the
[Packaging model](packaging-model.md) explanation.

---

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