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
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_appadd to deps:{:my_package, path: "../test_my_package"} mix deps.get && deps.compile && compile
And the deal with any errors along the way,
Also Liked
kip
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
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
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?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









