@@ -4,10 +4,14 @@
44
55<title>Ruby</title>
66
7− <para>There currently is support to bundle applications that are packaged as Ruby gems. The utility "bundix" allows you to write a <filename>Gemfile</filename>, let bundler create a <filename>Gemfile.lock</filename>, and then convert
8− this into a nix expression that contains all Gem dependencies automatically.</para>
7+<para>There currently is support to bundle applications that are packaged as
8+Ruby gems. The utility "bundix" allows you to write a
9+<filename>Gemfile</filename>, let bundler create a
10+<filename>Gemfile.lock</filename>, and then convert this into a nix
11+expression that contains all Gem dependencies automatically.
12+</para>
913
10− <para>For example, to package sensu, we did:</para>
14+<para>For example, to package sensu, we did:</para>
1115
1216<screen>
1317<![CDATA[$ cd pkgs/servers/monitoring
@@ -38,14 +42,20 @@ bundlerEnv rec {
3842}]]>
3943</screen>
4044
41−<para>Please check in the <filename>Gemfile</filename>, <filename>Gemfile.lock</filename> and the <filename>gemset.nix</filename> so future updates can be run easily.
45+<para>Please check in the <filename>Gemfile</filename>,
46+<filename>Gemfile.lock</filename> and the
47+<filename>gemset.nix</filename> so future updates can be run easily.
4248</para>
4349
44−<para>For tools written in Ruby - i.e. where the desire is to install a package and then execute e.g. <command>rake</command> at the command line, there is an alternative builder called <literal>bundlerApp</literal>. Set up the <filename>gemset.nix</filename> the same way, and then, for example:
50+<para>For tools written in Ruby - i.e. where the desire is to install
51+a package and then execute e.g. <command>rake</command> at the command
52+line, there is an alternative builder called <literal>bundlerApp</literal>.
53+Set up the <filename>gemset.nix</filename> the same way, and then, for
54+example:
4555</para>
4656
4757<screen>
48− <![CDATA[{ lib, bundlerApp }:
58+<![CDATA[{ lib, bundlerApp }:
4959
5060bundlerApp {
5161 pname = "corundum";
@@ -60,15 +70,33 @@ bundlerApp {
6070 platforms = platforms.unix;
6171 };
6272}]]>
73+</screen>
6374
64−<para>The chief advantage of <literal>bundlerApp</literal> over <literal>bundlerEnv</literal> is the executables introduced in the environment are precisely those selected in the <literal>exes</literal> list, as opposed to <literal>bundlerEnv</literal> which adds all the executables made available by gems in the gemset, which can mean e.g. <command>rspec</command> or <command>rake</command> in unpredictable versions available from various packages.
75+<para>The chief advantage of <literal>bundlerApp</literal> over
76+<literal>bundlerEnv</literal> is the executables introduced in the
77+environment are precisely those selected in the <literal>exes</literal>
78+list, as opposed to <literal>bundlerEnv</literal> which adds all the
79+executables made available by gems in the gemset, which can mean e.g.
80+<command>rspec</command> or <command>rake</command> in unpredictable
81+versions available from various packages.
82+</para>
6583
66−<para>Resulting derivations for both builders also have two helpful attributes, <literal>env</literal> and <literal>wrapper</literal>. The first one allows one to quickly drop into
67−<command>nix-shell</command> with the specified environment present. E.g. <command>nix-shell -A sensu.env</command> would give you an environment with Ruby preset
68−so it has all the libraries necessary for <literal>sensu</literal> in its paths. The second one can be used to make derivations from custom Ruby scripts which have
69−<filename>Gemfile</filename>s with their dependencies specified. It is a derivation with <command>ruby</command> wrapped so it can find all the needed dependencies.
70−For example, to make a derivation <literal>my-script</literal> for a <filename>my-script.rb</filename> (which should be placed in <filename>bin</filename>) you should
71−run <command>bundix</command> as specified above and then use <literal>bundlerEnv</literal> like this:</para>
84+<para>Resulting derivations for both builders also have two helpful
85+attributes, <literal>env</literal> and <literal>wrapper</literal>.
86+The first one allows one to quickly drop into
87+<command>nix-shell</command> with the specified environment present.
88+E.g. <command>nix-shell -A sensu.env</command> would give you an
89+environment with Ruby preset so it has all the libraries necessary
90+for <literal>sensu</literal> in its paths. The second one can be
91+used to make derivations from custom Ruby scripts which have
92+<filename>Gemfile</filename>s with their dependencies specified. It is
93+a derivation with <command>ruby</command> wrapped so it can find all
94+the needed dependencies. For example, to make a derivation
95+<literal>my-script</literal> for a <filename>my-script.rb</filename>
96+(which should be placed in <filename>bin</filename>) you should run
97+<command>bundix</command> as specified above and then use
98+<literal>bundlerEnv</literal> like this:
99+</para>
72100
73101<programlisting>
74102<![CDATA[let env = bundlerEnv {