# `Minga.Extension.Hex`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/extension/hex.ex#L1)

Resolves hex-sourced extensions via Mix.install/2.

All hex extensions are installed in a single `Mix.install/2` call at
startup. This handles dependency resolution, downloading, and
compilation. Results are cached by Mix (keyed on the dep list hash),
so subsequent boots with the same extensions skip all network and
compilation work.

## Limitations

`Mix.install/2` can only be called once per VM (or again with
`force: true`). On config reload, if the hex dep list changed, we
call `Mix.install/2` with `force: true` to reinstall everything.

# `mix_dep`

```elixir
@type mix_dep() :: {atom(), String.t()} | {atom(), String.t(), keyword()}
```

A Mix dep tuple ready for Mix.install/2.

# `collect_hex_deps`

```elixir
@spec collect_hex_deps(GenServer.server()) :: [mix_dep()]
```

Collects hex deps from the registry as Mix.install-compatible tuples.

Returns a list like `[{:minga_snippets, "~> 0.3"}, {:other_ext, ">= 0.0.0"}]`.
Extensions without a version constraint default to `">= 0.0.0"` (latest).

# `install_all`

```elixir
@spec install_all() :: :ok | {:error, String.t()}
```

Installs all hex-sourced extensions from the registry via Mix.install/2.

Collects every extension with `source_type: :hex`, builds a dep list,
and calls `Mix.install/2` once. Returns `:ok` if successful or if
there are no hex extensions. Returns `{:error, reason}` if Mix.install
fails (network error, resolution failure, compile error).

After a successful install, extension modules are on the code path
and can be loaded with `Code.ensure_loaded?/1`.

# `install_all`

```elixir
@spec install_all(GenServer.server()) :: :ok | {:error, String.t()}
```

# `reinstall_all`

```elixir
@spec reinstall_all() :: :ok | {:error, String.t()}
```

Reinstalls all hex extensions with `force: true`.

Used during config reload when the hex dep list has changed. Forces
Mix.install/2 to re-resolve, re-download, and re-compile everything.

# `reinstall_all`

```elixir
@spec reinstall_all(GenServer.server()) :: :ok | {:error, String.t()}
```

---

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