There is probably more than one way to accomplish having a closed source OTP dependency, but here is one suggested method that should work.
Here is an example closed dependency in a git repository (only the rebar.config
and ebin
folder are present): https://github.com/potatosalad/erlang-closed-example/tree/closed (the source for the project is on the master branch).
If you were to host the closed sources files from ebin
and priv
and add a rebar.config
file to your own git repository, the following should work the same. Also, make sure your git repository is hosted somewhere private (unless the license for the project says otherwise).
You should be able to add the closed source repository as a dependency to your mix.exs
file:
defmodule Example.Mixfile do
use Mix.Project
def project do
[app: :example,
version: "0.0.1",
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end
def application do
[applications: [:logger, :closed]]
end
defp deps do
[{:closed, git: "https://github.com/potatosalad/erlang-closed-example.git", branch: "closed"}]
end
end
A full example project is available here: https://github.com/potatosalad/mix-closed-example
After running mix deps.get
, I can do the following in a iex -S mix
shell:
iex> :closed.secret()
"this is a closed source library"
The shared object files under priv
should also work, but will be dependent on the OS and available library versions.