# `Precompiled.Host`
[🔗](https://github.com/TomHoenderdos/elixir_precompiled/blob/v0.2.1/lib/precompiled/host.ex#L5)

Install signed, verified precompiled dependency builds instead of
compiling them.

Opt in with `config :precompiled, source: url`. In a Mix project
the `mix precompiled.deps` task, reached through the project's
`deps.loadpaths` alias, calls `run/1` before Mix compiles the
dependencies (the Nerves `nerves.init` hook calls it the same way);
`install/2` wraps `Mix.install/2`. Every candidate dependency prints HIT,
MISS or FAIL with a reason, and the same list lands in
`_build/<target>_<env>/lib/.precompiled/report.json`.

# `report`

```elixir
@type report() :: %{
  hits: non_neg_integer(),
  misses: non_neg_integer(),
  fails: non_neg_integer(),
  bytes: non_neg_integer(),
  seconds: float(),
  lines: [term()]
}
```

What a run did: counts of hits, misses and failures, the bytes
installed, the time taken and one printed line per candidate.

# `install`

```elixir
@spec install([term()], keyword()) :: :ok
```

`Mix.install/2` with precompiled builds: resolves `deps`, installs every
matching build into the install project, then calls `Mix.install/2`,
which compiles only the rest. Takes `Mix.install/2`'s options plus
`:source`, `:except`, `:root` and `:home` (see `Precompiled.Config`);
without a source, configured or given, it is a plain `Mix.install/2`.

Needs Mix on the device (`:mix` in `extra_applications`), a writable
`MIX_INSTALL_DIR`, and Hex.

# `run`

```elixir
@spec run(keyword()) :: :disabled | :nothing_to_do | {:ok, report()}
```

The build-time step: check every dependency Mix is about to compile and
install the matching builds. `:disabled` without a source, and on the host
target unless `allow_host: true` (what `mix precompiled.deps` passes);
`host?: true | false` forces either.

---

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