-
Notifications
You must be signed in to change notification settings - Fork 64
hexpm
HexPM repository is the package manager for Elixir and Erlang packages. Here is the configuration example for HexPM repository:
# my_hexpm.yaml file
repo:
type: hexpm
storage:
type: fs
path: /var/artipie/data/
Repository name is the name of the repo config yaml file(e.g. my_hexpm
).
Check storage documentation to learn more about storage settings.
To use your HexPM repository in Elixir project with mix
build tool, add the following configuration
into mix.exs
project file (alternatively configure it via mix hex.config or system environment):
# mix.exs file
def project() do
[
# ...
deps: deps(),
hex: hex()
]
end
defp deps do
[
{:my_artifact, "~> 1.0.0", repo: "my_hexpm"}
]
end
defp hex() do
[
unsafe_registry: true,
no_verify_repo_origin: true
]
end
You must add repo to hex
,
that is directed to your HexPM repository(e.g. name is my_hexpm
) with the next command:
mix hex.repo add <repo_name> http://<artipie_host>:<artipie_port>/<repo_name>
mix hex.repo add my_hexpm http://artipie:8080/my_hexpm
To verify that repo has been added, use the following command:
mix hex.repo list
- To download a package(e.g. my_artifact with version 1.0.0) from
my_hexpm
you can use the command:
mix hex.package fetch <artifact_name> <version> --repo=<repo_name>
mix hex.package fetch my_artifact 1.0.0 --repo=my_hexpm
- For fetching all dependencies, you can add dependencies in
deps
function inmix.exs
:
# mix.exs file
def project() do
[
# ...
deps: deps()
]
end
defp deps do
[
{:my_first_artifact, "~> 1.0.1", repo: "my_hexpm"},
{:my_second_artifact, "~> 2.2.0", repo: "my_hexpm"}
]
end
and use the following command:
mix deps.get
- Via rest api
You can create tar archive of your mix project with the next command:
mix hex.build
If you have completed tar archive, you can upload it to your HexPM repository with the next command:
curl -X POST --data-binary "@<path_to_tar>/<tar>" http://<artipie_host>:<artipie_port>/<repo_name>/publish?replace=false
curl -X POST --data-binary "@./decimal-2.0.0.tar" http://artipie:8080/my_hexpm/publish?replace=false
If version already exist in your HexPM repository, and you want to replace it, use true
in query param replace
:
curl -X POST --data-binary "@<path_to_tar>/<tar>" http://<artipie_host>:<artipie_port>/<repo_name>/publish?replace=true
- Publish via mix
⚠ Note |
---|
To run this command you need to have an authenticated user on your local machine, run mix hex.user register to register or mix hex.user auth to authenticate with an existing user, if you already have account at hexpm. |
For publish package in your HexPM repository you must change api_url
in mix.exs
file:
# mix.exs file
def project() do
[
# ...
hex: hex()
]
end
defp hex() do
[
api_url: "http://<artipie_host>:<artipie_port>/<repo_name>"
]
end
You can also override it with an environment variable(HEX_API_URL) or with mix hex.config
.
Then you can use the following command to publish artifact of your mix project:
mix hex.publish package
If version already exist in your HexPM repository, and you want to replace it, add --replace
to command:
mix hex.publish package --replace