Using Elixir dependencies in Erlang (umbrella) apps

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Using Elixir dependencies in Erlang (umbrella) apps

Marc Worrell
Hi,

We are investigating if it is possible to use Elixir apps in Erlang projects.

There are a couple of rebar3 plugins that aim to make this possible:

https://hex.pm/packages/rebar3_elixir_plugin

https://hex.pm/packages/rebar3_elixirc

https://hex.pm/packages/rebar3_elixir_compile

Has anybody any experience using these plugins?

We have an umbrella Erlang app and would like to be able to
use some Elixir libraries that don’t have good Erlang equivalents.

Might also be an option to turn our Erlang umbrella app into an Elixir
umbrella app, anybody having experience with that? The top level Erlang
source code is next to nothing.

Cheers,

Marc
Reply | Threaded
Open this post in threaded view
|

Re: Using Elixir dependencies in Erlang (umbrella) apps

Roger Lipscombe-2
On Fri, 1 May 2020 at 10:59, Marc Worrell <[hidden email]> wrote:
> Might also be an option to turn our Erlang umbrella app into an Elixir
> umbrella app, anybody having experience with that? The top level Erlang
> source code is next to nothing.

We've done this. You'll need a top-level mix.exs that looks something like this:

defmodule ErlangWithMix.MixProject do
  use Mix.Project

  def project do
    [
      apps_path: "apps",
      version: "0.1.0",
      deps: deps()
    ]
  end

  defp deps do
    [
      # Because of the only: [:test] here, "mix eunit" and "mix ct" aren't
      # available unless you _first_ "MIX_ENV=test mix compile", and
      # even then you need "MIX_ENV=test" every time.
      {:mix_eunit, git: "https://github.com/rlipscombe/mix_eunit",
runtime: false, only: [:test]},
      {:mix_ct, git: "https://github.com/rlipscombe/mix_ct", runtime:
false, only: [:test]},

      {:mix_relx, git: "https://github.com/rlipscombe/mix_relx", runtime: false}
    ]
  end
end

Then you'll need https://github.com/rlipscombe/mix_erl_new/
Reply | Threaded
Open this post in threaded view
|

Re: Using Elixir dependencies in Erlang (umbrella) apps

Roger Lipscombe-2
On Fri, 1 May 2020 at 12:35, Roger Lipscombe <[hidden email]> wrote:
>
> On Fri, 1 May 2020 at 10:59, Marc Worrell <[hidden email]> wrote:
> > Might also be an option to turn our Erlang umbrella app into an Elixir
> > umbrella app, anybody having experience with that? The top level Erlang
> > source code is next to nothing.
>
> We've done this. You'll need a top-level mix.exs that looks something like this:

...except that this is for an entirely-Erlang umbrella project that
uses mix for compilation. We've not -- yet -- put any Elixir projects
in the same umbrella. It ought to work fine, though.
Reply | Threaded
Open this post in threaded view
|

Re: Using Elixir dependencies in Erlang (umbrella) apps

Roger Lipscombe-2
On Fri, 1 May 2020 at 12:36, Roger Lipscombe <[hidden email]> wrote:
>
> On Fri, 1 May 2020 at 12:35, Roger Lipscombe <[hidden email]> wrote:
> >
> > On Fri, 1 May 2020 at 10:59, Marc Worrell <[hidden email]> wrote:
> > > Might also be an option to turn our Erlang umbrella app into an Elixir
> > > umbrella app, anybody having experience with that? The top level Erlang
> > > source code is next to nothing.
> >
> > We've done this.

Hmmm. I should probably recommend that you try the other approaches
first, since you're likely to get better support with them. If you do
what we did, your only source of support is, well, me.
Reply | Threaded
Open this post in threaded view
|

Re: Using Elixir dependencies in Erlang (umbrella) apps

Leonard Boyce-2
In reply to this post by Marc Worrell
Hi Marc,

We're using Elixir deps in umbrella apps for a couple of years.
There may be better approaches now.

Small slice from rebar.config which may help

{deps, [...,
          {ua_inspector, {elixir, "ua_inspector",
                        {git, "URL",
                         {branch, "BRANCH"}}}},
          ....]}.
 {plugins, [
     rebar3_hex,
    { provider_asn1, "0.2.0"},
    {rebar3_elixir_compile, ".*", {git,
"https://github.com/loucash/rebar3_elixir_compile.git", {branch,
"master"}}}
 ]}.

{provider_hooks, [
  {pre, [{compile, {ex, compile}}]}
]}.

{elixir_opts, [{env, dev}]}.

{relx, [{release, {"RELNAME", "VERSION"}, [MODS]},
          {lib_dirs,
["_elixir_build/ua_inspector/_build/dev/lib/ua_inspector/"]},
          ....]}.


On Fri, May 1, 2020 at 5:59 AM Marc Worrell <[hidden email]> wrote:

>
> Hi,
>
> We are investigating if it is possible to use Elixir apps in Erlang projects.
>
> There are a couple of rebar3 plugins that aim to make this possible:
>
> https://hex.pm/packages/rebar3_elixir_plugin
>
> https://hex.pm/packages/rebar3_elixirc
>
> https://hex.pm/packages/rebar3_elixir_compile
>
> Has anybody any experience using these plugins?
>
> We have an umbrella Erlang app and would like to be able to
> use some Elixir libraries that don’t have good Erlang equivalents.
>
> Might also be an option to turn our Erlang umbrella app into an Elixir
> umbrella app, anybody having experience with that? The top level Erlang
> source code is next to nothing.
>
> Cheers,
>
> Marc
Reply | Threaded
Open this post in threaded view
|

Re: Using Elixir dependencies in Erlang (umbrella) apps

Tristan Sloughter-4
In reply to this post by Marc Worrell
Those are for compiling elixir code, not for compiling mix projects. See https://github.com/Supersonido/rebar_mix for a plugin that can build mix projects.

On Fri, May 1, 2020, at 03:59, Marc Worrell wrote:

> Hi,
>
> We are investigating if it is possible to use Elixir apps in Erlang projects.
>
> There are a couple of rebar3 plugins that aim to make this possible:
>
> https://hex.pm/packages/rebar3_elixir_plugin
>
> https://hex.pm/packages/rebar3_elixirc
>
> https://hex.pm/packages/rebar3_elixir_compile
>
> Has anybody any experience using these plugins?
>
> We have an umbrella Erlang app and would like to be able to
> use some Elixir libraries that don’t have good Erlang equivalents.
>
> Might also be an option to turn our Erlang umbrella app into an Elixir
> umbrella app, anybody having experience with that? The top level Erlang
> source code is next to nothing.
>
> Cheers,
>
> Marc
Reply | Threaded
Open this post in threaded view
|

Re: Using Elixir dependencies in Erlang (umbrella) apps

Mikael Karlsson-7
In reply to this post by Marc Worrell
Hi Marc,

> Might also be an option to turn our Erlang umbrella app into an Elixir
> umbrella app, anybody having experience with that? The top level Erlang
> source code is next to nothing.

Seems someone already has been experimenting with using mix in zotonic and mixing erlang and elixir code (and converting erlang to elixir). Don't know if it can be of any use:
https://groups.google.com/forum/#!topic/zotonic-users/pwgAdjeSDWA