lol

erlang: update documentation.

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.

+120 -42
+110 -30
doc/languages-frameworks/beam.xml
··· 2 2 xmlns:xlink="http://www.w3.org/1999/xlink" 3 3 xml:id="sec-beam"> 4 4 5 - <title>Beam Languages (Erlang &amp; Elixir)</title> 5 + <title>Beam Languages (Erlang, Elixir &amp; LFE)</title> 6 6 <section xml:id="beam-introduction"> 7 7 <title>Introduction</title> 8 8 <para> 9 9 In this document and related Nix expressions we use the term 10 - <emphasis>Beam</emphasis> to describe the environment. Beam is 10 + <emphasis>Beam</emphasis> to describe the environment. BEAM is 11 11 the name of the Erlang Virtial Machine and, as far as we know, 12 - from a packaging perspective all languages that run on Beam are 12 + from a packaging perspective all languages that run on BEAM are 13 13 interchangable. The things that do change, like the build 14 14 system, are transperant to the users of the package. So we make 15 15 no distinction. 16 16 </para> 17 17 </section> 18 - <section xml:id="build-tools"> 18 + <section xml:id="beam-structure"> 19 + <title>Structure</title> 20 + <para> 21 + All Beam-related things are available via top-level 22 + <literal>beam</literal> attribute, which includes: 23 + </para> 24 + <itemizedlist> 25 + <listitem> 26 + <para> 27 + <literal>interpreters</literal>: contains a set of compilers running 28 + on Beam, including multiple Erlang/OTP versions 29 + (<literal>beam.interpreters.erlangR19</literal>, etc), Elixir 30 + (<literal>beam.interpreters.elixir</literal>) and LFE 31 + (<literal>beam.interpreters.lfe</literal>). 32 + </para> 33 + </listitem> 34 + <listitem> 35 + <para> 36 + <literal>packages</literal>: contains a set of package sets, each 37 + compiled with a specific Erlang/OTP version, e.g. 38 + <literal>beam.packages.erlangR19</literal>. 39 + </para> 40 + </listitem> 41 + </itemizedlist> 42 + <para> 43 + Default Erlang compiler is defined by 44 + <literal>beam.interpreters.erlang</literal> and aliased as 45 + <literal>erlang</literal>. Default package set with Beam packages is 46 + defined by <literal>beam.packages.erlang</literal> and aliased at 47 + top-level as <literal>beamPackages</literal>. 48 + </para> 49 + <para> 50 + If you want to create a package set built with a custom Erlang version, 51 + use lambda <literal>beam.packagesWith</literal>, which accepts an 52 + Erlang/OTP derivative and produces a package set similar to 53 + <literal>beam.packages.erlang</literal>. 54 + </para> 55 + <para> 56 + Many Erlang/OTP distributions available in 57 + <literal>beam.interpreters</literal> have their versions with ODBC and/or 58 + Java enabled. For example there's 59 + <literal>beam.interpreters.erlangR19_odbc_javac</literal> which 60 + corresponds to <literal>beam.interpreters.erlangR19</literal>. 61 + </para> 62 + <para> 63 + We also provide <literal>beam.packages.erlang.callPackage</literal>, which 64 + simplifies writing Beam package definitions, by injecting all packages from 65 + <literal>beam.packages.erlang</literal> into top-level context. 66 + </para> 67 + </section> 68 + <section xml:id="build-tools"> 19 69 <title>Build Tools</title> 20 70 <section xml:id="build-tools-rebar3"> 21 71 <title>Rebar3</title> 22 72 <para> 23 - By default Rebar3 wants to manage it's own dependencies. In the 24 - normal non-Nix, this is perfectly acceptable. In the Nix world it 25 - is not. To support this we have created two versions of rebar3, 73 + By default Rebar3 wants to manage it's own dependencies. This is perfectly 74 + acceptable in the normal non-Nix setup. In the Nix world it is not. To 75 + support this we have created two versions of rebar3, 26 76 <literal>rebar3</literal> and <literal>rebar3-open</literal>. The 27 - <literal>rebar3</literal> version has been patched to remove the 28 - ability to download anything from it. If you are not running it a 29 - nix-shell or a nix-build then its probably not going to work for 30 - you. <literal>rebar3-open</literal> is the normal, un-modified 31 - rebar3. It should work exactly as would any other version of 32 - rebar3. Any Erlang package should rely on 33 - <literal>rebar3</literal> and thats really what you should be 34 - using too. 77 + <literal>rebar3</literal> version has been patched to remove the ability 78 + to download anything from it. If you are not running it a nix-shell or a 79 + nix-build then its probably not going to work for you. 80 + <literal>rebar3-open</literal> is the normal, un-modified rebar3. It 81 + should work exactly as would any other version of rebar3. Any Erlang 82 + package should rely on <literal>rebar3</literal> and thats really what you 83 + should be using too. See <literal>buildRebar3</literal> below. 35 84 </para> 36 85 </section> 37 86 <section xml:id="build-tools-other"> ··· 43 92 <literal>buildMix</literal> and <literal>buildErlangMk</literal> derivations. 44 93 </para> 45 94 </section> 46 - 47 95 </section> 48 96 49 97 <section xml:id="how-to-install-beam-packages"> 50 98 <title>How to install Beam packages</title> 51 99 <para> 52 - Beam packages are not registered in the top level simply because 53 - they are not relevant to the vast majority of Nix users. They are 54 - installable using the <literal>beamPackages</literal> attribute 55 - set. 100 + Beam packages are not registered in the top level simply because they are 101 + not relevant to the vast majority of Nix users. They are installable using 102 + the <literal>beam.packages.erlang</literal> attribute set and aliased as 103 + <literal>beamPackages</literal>. This attribute points at packages built by 104 + the default Erlang/OTP version in Nixpkgs as defined by 105 + <literal>beam.interpreters.erlang</literal>. 56 106 57 107 You can list the avialable packages in the 58 108 <literal>beamPackages</literal> with the following command: ··· 87 137 <section xml:id="rebar3-packages"> 88 138 <title>Rebar3 Packages</title> 89 139 <para> 90 - There is a Nix functional called 91 - <literal>buildRebar3</literal>. We use this function to make a 92 - derivation that understands how to build the rebar3 project. For 93 - example, the epression we use to build the <link 140 + There is a Nix function called <literal>buildRebar3</literal> (defined 141 + in <literal>beam.packages.erlang.buildRebar3</literal> and aliased at 142 + top-level). We use this function to make a derivation that understands 143 + how to build the rebar3 project. For example, the expression we use to 144 + build the <link 94 145 xlink:href="https://github.com/erlang-nix/hex2nix">hex2nix</link> 95 146 project follows. 96 147 </para> ··· 112 163 } 113 164 </programlisting> 114 165 <para> 166 + This derivation is callable with 167 + <literal>beam.packages.erlang.callPackage</literal> (see above). If you 168 + want to call this package using normal <literal>callPackage</literal>, 169 + you should refer to dependency packages via 170 + <literal>beamPackages</literal>, e.g. 171 + <literal>beamPackages.ibrowse</literal>. 172 + </para> 173 + <para> 115 174 The only visible difference between this derivation and 116 175 something like <literal>stdenv.mkDerivation</literal> is that we 117 - have added <literal>erlangDeps</literal> to the derivation. If 176 + have added <literal>beamDeps</literal> to the derivation. If 118 177 you add your Beam dependencies here they will be correctly 119 178 handled by the system. 120 179 </para> ··· 171 230 sha256 = 172 231 "08459823fe1fd4f0325a8bf0c937a4520583a5a26d73b193040ab30a1dfc0b33"; 173 232 }; 233 + beamDeps = [ plug absinthe ]; 234 + 235 + meta = { 236 + description = ''A plug for Absinthe, an experimental GraphQL 237 + toolkit''; 238 + license = stdenv.lib.licenses.bsd3; 239 + homepage = "https://github.com/CargoSense/absinthe_plug"; 240 + }; 241 + } 242 + </programlisting> 243 + <para> 244 + Alternatively one can use <literal>buildHex</literal> as a shortcut for the above: 245 + </para> 246 + <programlisting> 247 + { buildHex, buildMix, plug, absinthe }: 248 + buildHex { 249 + name = "absinthe_plug"; 250 + version = "1.0.0"; 251 + sha256 = 252 + "08459823fe1fd4f0325a8bf0c937a4520583a5a26d73b193040ab30a1dfc0b33"; 253 + builder = buildMix; 174 254 beamDeps = [ plug absinthe]; 175 255 176 256 meta = { ··· 264 344 name = "hex2nix"; 265 345 version = "0.1.0"; 266 346 src = ./.; 267 - erlangDeps = [ ibrowse jsx erlware_commons ]; 347 + beamDeps = [ ibrowse jsx erlware_commons ]; 268 348 }; 269 349 drv = beamPackages.callPackage f {}; 270 350 ··· 272 352 drv 273 353 </programlisting> 274 354 <section xml:id="building-in-a-shell"> 275 - <title>Building in a shell</title> 355 + <title>Building in a shell (for mix projects)</title> 276 356 <para> 277 - We can leveral the support of the Derivation, regardless of 278 - which build Derivation is called by calling the commands themselv.s 357 + We can leverage the support of the Derivation, regardless of 358 + which build Derivation is called by calling the commands themselves. 279 359 </para> 280 360 <programlisting> 281 361 # ============================================================================= ··· 351 431 <literal>hex2nix</literal> tool. Given the path to the Erlang 352 432 modules (usually 353 433 <literal>pkgs/development/erlang-modules</literal>). It will 354 - happily dump a file called 434 + dump a file called 355 435 <literal>hex-packages.nix</literal>. That file will contain all 356 436 the packages that use a recognized build system in Hex. However, 357 437 it can't know whether or not all those packages are buildable.
+9 -11
pkgs/development/beam-modules/mix-bootstrap
··· 3 3 %%! -smp enable 4 4 %%% --------------------------------------------------------------------------- 5 5 %%% @doc 6 - %%% The purpose of this command is to prepare a rebar3 project so that 7 - %%% rebar3 understands that the dependencies are all already 8 - %%% installed. If you want a hygienic build on nix then you must run 9 - %%% this command before running rebar3. I suggest that you add a 10 - %%% `Makefile` to your project and have the bootstrap command be a 11 - %%% dependency of the build commands. See the nix documentation for 6 + %%% The purpose of this command is to prepare a mix project so that mix 7 + %%% understands that the dependencies are all already installed. If you want a 8 + %%% hygienic build on nix then you must run this command before running mix. I 9 + %%% suggest that you add a `Makefile` to your project and have the bootstrap 10 + %%% command be a dependency of the build commands. See the nix documentation for 12 11 %%% more information. 13 12 %%% 14 - %%% This command designed to have as few dependencies as possible so 15 - %%% that it can be a dependency of root level packages like rebar3. To 16 - %%% that end it does many things in a fairly simplistic way. That is 17 - %%% by design. 13 + %%% This command designed to have as few dependencies as possible so that it can 14 + %%% be a dependency of root level packages like mix. To that end it does many 15 + %%% things in a fairly simplistic way. That is by design. 18 16 %%% 19 17 %%% ### Assumptions 20 18 %%% ··· 37 35 38 36 %% @doc 39 37 %% This takes an app name in the standard OTP <name>-<version> format 40 - %% and returns just the app name. Why? because rebar is doesn't 38 + %% and returns just the app name. Why? Because rebar doesn't 41 39 %% respect OTP conventions in some cases. 42 40 -spec fixup_app_name(file:name()) -> string(). 43 41 fixup_app_name(Path) ->
+1 -1
pkgs/development/tools/build-managers/rebar3/rebar3-nix-bootstrap
··· 146 146 147 147 %% @doc 148 148 %% This takes an app name in the standard OTP <name>-<version> format 149 - %% and returns just the app name. Why? because rebar doesn't 149 + %% and returns just the app name. Why? Because rebar doesn't 150 150 %% respect OTP conventions in some cases. 151 151 -spec fixup_app_name(string()) -> string(). 152 152 fixup_app_name(FileName) ->