arcadian

arcadian

Where can I learn how to release my own library as a hex package?

I’ve been learning about Elixir Nif’s for a while, and it looks like I will have my first library to release shortly and could use some help with learning how that process works. It is a fixed-row caching library, and IMHO it is a gamechanger for elixir apps that are planning to use or that are already using embedded node-local storage (i.e. sqlite, dets, cubdb, leveldb, etc). Details to follow.

I could use some help with understanding the process associated with releasing a library as a hex package and on github or a similar site (I don’t know what the best alternative is nowadays). Any pointers, info, insights would be greatly appreciated, especially if they are Nif related.

FWIW, I am currently doing my compilation like this, which is fine for testing but won’t fly for a release I know:

  def project do
    [
      app: :daphne,
      version: "0.1.0",
      elixir: "~> 1.14",
      start_permanent: Mix.env() == :prod,
      compilers: Mix.compilers ++ [:NifBuilder],     <<====  set custom compiler in mix.exs
      deps: deps()
    ]
  end
defmodule Mix.Tasks.Compile.NifBuilder do
  def run(_args) do
    {result, _errcode} = System.cmd("gmake", [], stderr_to_stdout: true)
    IO.binwrite(result)
  end
end

Marked As Solved

kip

kip

ex_cldr Core Team

I’d suggest take a look at:

  • Decimal for a simple package example
  • ex_cldr for a more complex packaging example but no NIF
  • vix for an example of a NIF-based package

When I’m testing a new application that is intended to be published, I find the following useful:

  • In the app (lets call it my_package) that will become a package: mix hex.build -o ../test_my_package --unpack
  • Create a dummy app, my_app
  • In my_app add to deps: {:my_package, path: "../test_my_package"}
  • mix deps.get && deps.compile && compile

And the deal with any errors along the way,

10
Post #8

Also Liked

kip

kip

ex_cldr Core Team

I’d suggest starting with the official publishing guide. It’s pretty straight forward. You can test your build process with mix hex.build.

axelson

axelson

Scenic Core Team

Since your library contains a nif you’ll probably also want to look at GitHub - elixir-lang/elixir_make: A Make compiler for Mix which helps compiling code without calling make/gmake directly (since which one you use might be platform dependent).

kip

kip

ex_cldr Core Team

In general, any mix-based app can be configured as a dependency. There are particular rules if you also want to publish to hex.pm

What have you tried and what issues have you found?

arcadian

arcadian

I guess I am unclear on how to turn my app into a dependency.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement