Today we are releasing the first version of hex_core, an Erlang library to interact with Hex.pm and other servers implementing Hex specifications.
Before talking about hex_core, let’s ask a simple question: What is Hex? The short answer is, it’s a package manager for the Erlang ecosystem. The long answer is that by Hex we may mean a few different things:
The goal of hex_core is to be the reference implementation of Hex specifications used by Hex clients and servers.
As of this announcement the hex_core package itself is available on Hex.pm.
Create a new project: rebar3 new lib example
Add hex_core
to rebar.config
:
{deps, [
{hex_core, "0.1.0"}
]}
Start the shell to and count all packages published to Hex.pm:
$ rebar3 shell
erl> inets:start(), ssl:start(),
erl> Config = hex_core:default_config(),
erl> {ok, {200, _, #{packages := Packages}}} = hex_repo:get_names(Config),
erl> length(Packages).
6764
Create a new project: mix new example
Add hex_core
to mix.exs
:
defp deps() do
[{:hex_core, "~> 0.1"}]
end
Start the shell to and search for all packages matching query “riak”:
$ iex -S mix
iex> :inets.start() ; :ssl.start()
iex> config = :hex_core.default_config()
iex> options = [sort: :downloads]
iex> {:ok, {200, _, packages}} = :hex_api_package.search(config, "riak", options)
iex> Enum.map(packages, & &1["name"])
["riak_pb", "riakc", ...]
See README at https://github.com/hexpm/hex_core for more usage examples.
After the initial release we plan to work with the community to integrate hex_core into their projects and respond to feedback.
We will also be focused on releasing a minimal Hex server, built on top of hex_core, to be a starting point for people wanting to run Hex on their own infrastructure. Stay tuned!