The documentation got a bit stale compared to actual contents of nixpkgs. This commit focuses on updating existing docs, not on making sure all details of beam packages are covered.
···22 xmlns:xlink="http://www.w3.org/1999/xlink"
33 xml:id="sec-beam">
4455- <title>Beam Languages (Erlang & Elixir)</title>
55+ <title>Beam Languages (Erlang, Elixir & LFE)</title>
66 <section xml:id="beam-introduction">
77 <title>Introduction</title>
88 <para>
99 In this document and related Nix expressions we use the term
1010- <emphasis>Beam</emphasis> to describe the environment. Beam is
1010+ <emphasis>Beam</emphasis> to describe the environment. BEAM is
1111 the name of the Erlang Virtial Machine and, as far as we know,
1212- from a packaging perspective all languages that run on Beam are
1212+ from a packaging perspective all languages that run on BEAM are
1313 interchangable. The things that do change, like the build
1414 system, are transperant to the users of the package. So we make
1515 no distinction.
1616 </para>
1717 </section>
1818-<section xml:id="build-tools">
1818+ <section xml:id="beam-structure">
1919+ <title>Structure</title>
2020+ <para>
2121+ All Beam-related things are available via top-level
2222+ <literal>beam</literal> attribute, which includes:
2323+ </para>
2424+ <itemizedlist>
2525+ <listitem>
2626+ <para>
2727+ <literal>interpreters</literal>: contains a set of compilers running
2828+ on Beam, including multiple Erlang/OTP versions
2929+ (<literal>beam.interpreters.erlangR19</literal>, etc), Elixir
3030+ (<literal>beam.interpreters.elixir</literal>) and LFE
3131+ (<literal>beam.interpreters.lfe</literal>).
3232+ </para>
3333+ </listitem>
3434+ <listitem>
3535+ <para>
3636+ <literal>packages</literal>: contains a set of package sets, each
3737+ compiled with a specific Erlang/OTP version, e.g.
3838+ <literal>beam.packages.erlangR19</literal>.
3939+ </para>
4040+ </listitem>
4141+ </itemizedlist>
4242+ <para>
4343+ Default Erlang compiler is defined by
4444+ <literal>beam.interpreters.erlang</literal> and aliased as
4545+ <literal>erlang</literal>. Default package set with Beam packages is
4646+ defined by <literal>beam.packages.erlang</literal> and aliased at
4747+ top-level as <literal>beamPackages</literal>.
4848+ </para>
4949+ <para>
5050+ If you want to create a package set built with a custom Erlang version,
5151+ use lambda <literal>beam.packagesWith</literal>, which accepts an
5252+ Erlang/OTP derivative and produces a package set similar to
5353+ <literal>beam.packages.erlang</literal>.
5454+ </para>
5555+ <para>
5656+ Many Erlang/OTP distributions available in
5757+ <literal>beam.interpreters</literal> have their versions with ODBC and/or
5858+ Java enabled. For example there's
5959+ <literal>beam.interpreters.erlangR19_odbc_javac</literal> which
6060+ corresponds to <literal>beam.interpreters.erlangR19</literal>.
6161+ </para>
6262+ <para>
6363+ We also provide <literal>beam.packages.erlang.callPackage</literal>, which
6464+ simplifies writing Beam package definitions, by injecting all packages from
6565+ <literal>beam.packages.erlang</literal> into top-level context.
6666+ </para>
6767+ </section>
6868+ <section xml:id="build-tools">
1969 <title>Build Tools</title>
2070 <section xml:id="build-tools-rebar3">
2171 <title>Rebar3</title>
2272 <para>
2323- By default Rebar3 wants to manage it's own dependencies. In the
2424- normal non-Nix, this is perfectly acceptable. In the Nix world it
2525- is not. To support this we have created two versions of rebar3,
7373+ By default Rebar3 wants to manage it's own dependencies. This is perfectly
7474+ acceptable in the normal non-Nix setup. In the Nix world it is not. To
7575+ support this we have created two versions of rebar3,
2676 <literal>rebar3</literal> and <literal>rebar3-open</literal>. The
2727- <literal>rebar3</literal> version has been patched to remove the
2828- ability to download anything from it. If you are not running it a
2929- nix-shell or a nix-build then its probably not going to work for
3030- you. <literal>rebar3-open</literal> is the normal, un-modified
3131- rebar3. It should work exactly as would any other version of
3232- rebar3. Any Erlang package should rely on
3333- <literal>rebar3</literal> and thats really what you should be
3434- using too.
7777+ <literal>rebar3</literal> version has been patched to remove the ability
7878+ to download anything from it. If you are not running it a nix-shell or a
7979+ nix-build then its probably not going to work for you.
8080+ <literal>rebar3-open</literal> is the normal, un-modified rebar3. It
8181+ should work exactly as would any other version of rebar3. Any Erlang
8282+ package should rely on <literal>rebar3</literal> and thats really what you
8383+ should be using too. See <literal>buildRebar3</literal> below.
3584 </para>
3685 </section>
3786 <section xml:id="build-tools-other">
···4392 <literal>buildMix</literal> and <literal>buildErlangMk</literal> derivations.
4493 </para>
4594 </section>
4646-4795</section>
48964997<section xml:id="how-to-install-beam-packages">
5098 <title>How to install Beam packages</title>
5199 <para>
5252- Beam packages are not registered in the top level simply because
5353- they are not relevant to the vast majority of Nix users. They are
5454- installable using the <literal>beamPackages</literal> attribute
5555- set.
100100+ Beam packages are not registered in the top level simply because they are
101101+ not relevant to the vast majority of Nix users. They are installable using
102102+ the <literal>beam.packages.erlang</literal> attribute set and aliased as
103103+ <literal>beamPackages</literal>. This attribute points at packages built by
104104+ the default Erlang/OTP version in Nixpkgs as defined by
105105+ <literal>beam.interpreters.erlang</literal>.
5610657107 You can list the avialable packages in the
58108 <literal>beamPackages</literal> with the following command:
···87137 <section xml:id="rebar3-packages">
88138 <title>Rebar3 Packages</title>
89139 <para>
9090- There is a Nix functional called
9191- <literal>buildRebar3</literal>. We use this function to make a
9292- derivation that understands how to build the rebar3 project. For
9393- example, the epression we use to build the <link
140140+ There is a Nix function called <literal>buildRebar3</literal> (defined
141141+ in <literal>beam.packages.erlang.buildRebar3</literal> and aliased at
142142+ top-level). We use this function to make a derivation that understands
143143+ how to build the rebar3 project. For example, the expression we use to
144144+ build the <link
94145 xlink:href="https://github.com/erlang-nix/hex2nix">hex2nix</link>
95146 project follows.
96147 </para>
···112163 }
113164 </programlisting>
114165 <para>
166166+ This derivation is callable with
167167+ <literal>beam.packages.erlang.callPackage</literal> (see above). If you
168168+ want to call this package using normal <literal>callPackage</literal>,
169169+ you should refer to dependency packages via
170170+ <literal>beamPackages</literal>, e.g.
171171+ <literal>beamPackages.ibrowse</literal>.
172172+ </para>
173173+ <para>
115174 The only visible difference between this derivation and
116175 something like <literal>stdenv.mkDerivation</literal> is that we
117117- have added <literal>erlangDeps</literal> to the derivation. If
176176+ have added <literal>beamDeps</literal> to the derivation. If
118177 you add your Beam dependencies here they will be correctly
119178 handled by the system.
120179 </para>
···171230 sha256 =
172231 "08459823fe1fd4f0325a8bf0c937a4520583a5a26d73b193040ab30a1dfc0b33";
173232 };
233233+ beamDeps = [ plug absinthe ];
234234+235235+ meta = {
236236+ description = ''A plug for Absinthe, an experimental GraphQL
237237+ toolkit'';
238238+ license = stdenv.lib.licenses.bsd3;
239239+ homepage = "https://github.com/CargoSense/absinthe_plug";
240240+ };
241241+ }
242242+ </programlisting>
243243+ <para>
244244+ Alternatively one can use <literal>buildHex</literal> as a shortcut for the above:
245245+ </para>
246246+ <programlisting>
247247+ { buildHex, buildMix, plug, absinthe }:
248248+ buildHex {
249249+ name = "absinthe_plug";
250250+ version = "1.0.0";
251251+ sha256 =
252252+ "08459823fe1fd4f0325a8bf0c937a4520583a5a26d73b193040ab30a1dfc0b33";
253253+ builder = buildMix;
174254 beamDeps = [ plug absinthe];
175255176256 meta = {
···264344 name = "hex2nix";
265345 version = "0.1.0";
266346 src = ./.;
267267- erlangDeps = [ ibrowse jsx erlware_commons ];
347347+ beamDeps = [ ibrowse jsx erlware_commons ];
268348 };
269349 drv = beamPackages.callPackage f {};
270350···272352 drv
273353 </programlisting>
274354 <section xml:id="building-in-a-shell">
275275- <title>Building in a shell</title>
355355+ <title>Building in a shell (for mix projects)</title>
276356 <para>
277277- We can leveral the support of the Derivation, regardless of
278278- which build Derivation is called by calling the commands themselv.s
357357+ We can leverage the support of the Derivation, regardless of
358358+ which build Derivation is called by calling the commands themselves.
279359 </para>
280360 <programlisting>
281361# =============================================================================
···351431 <literal>hex2nix</literal> tool. Given the path to the Erlang
352432 modules (usually
353433 <literal>pkgs/development/erlang-modules</literal>). It will
354354- happily dump a file called
434434+ dump a file called
355435 <literal>hex-packages.nix</literal>. That file will contain all
356436 the packages that use a recognized build system in Hex. However,
357437 it can't know whether or not all those packages are buildable.
+9-11
pkgs/development/beam-modules/mix-bootstrap
···33%%! -smp enable
44%%% ---------------------------------------------------------------------------
55%%% @doc
66-%%% The purpose of this command is to prepare a rebar3 project so that
77-%%% rebar3 understands that the dependencies are all already
88-%%% installed. If you want a hygienic build on nix then you must run
99-%%% this command before running rebar3. I suggest that you add a
1010-%%% `Makefile` to your project and have the bootstrap command be a
1111-%%% dependency of the build commands. See the nix documentation for
66+%%% The purpose of this command is to prepare a mix project so that mix
77+%%% understands that the dependencies are all already installed. If you want a
88+%%% hygienic build on nix then you must run this command before running mix. I
99+%%% suggest that you add a `Makefile` to your project and have the bootstrap
1010+%%% command be a dependency of the build commands. See the nix documentation for
1211%%% more information.
1312%%%
1414-%%% This command designed to have as few dependencies as possible so
1515-%%% that it can be a dependency of root level packages like rebar3. To
1616-%%% that end it does many things in a fairly simplistic way. That is
1717-%%% by design.
1313+%%% This command designed to have as few dependencies as possible so that it can
1414+%%% be a dependency of root level packages like mix. To that end it does many
1515+%%% things in a fairly simplistic way. That is by design.
1816%%%
1917%%% ### Assumptions
2018%%%
···37353836%% @doc
3937%% This takes an app name in the standard OTP <name>-<version> format
4040-%% and returns just the app name. Why? because rebar is doesn't
3838+%% and returns just the app name. Why? Because rebar doesn't
4139%% respect OTP conventions in some cases.
4240-spec fixup_app_name(file:name()) -> string().
4341fixup_app_name(Path) ->
···146146147147%% @doc
148148%% This takes an app name in the standard OTP <name>-<version> format
149149-%% and returns just the app name. Why? because rebar doesn't
149149+%% and returns just the app name. Why? Because rebar doesn't
150150%% respect OTP conventions in some cases.
151151-spec fixup_app_name(string()) -> string().
152152fixup_app_name(FileName) ->