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 · GitHub 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?

Where Next?

Popular in Questions Top

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
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
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
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
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
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement