···42<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.
43</para>
440000000000000000000000000000000045</section>
46
···42<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.
43</para>
4445+<para>Resulting derivations also have two helpful items, <literal>env</literal> and <literal>wrapper</literal>. The first one allows one to quickly drop into
46+<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
47+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
48+<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.
49+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
50+run <command>bundix</command> as specified above and then use <literal>bundlerEnv</literal> lile this:</para>
51+52+<programlisting>
53+<![CDATA[let env = bundlerEnv {
54+ name = "my-script-env";
55+56+ inherit ruby;
57+ gemfile = ./Gemfile;
58+ lockfile = ./Gemfile.lock;
59+ gemset = ./gemset.nix;
60+};
61+62+in stdenv.mkDerivation {
63+ name = "my-script";
64+65+ buildInputs = [ env.wrapper ];
66+67+ script = ./my-script.rb;
68+69+ buildCommand = ''
70+ mkdir -p $out/bin
71+ install -D -m755 $script $out/bin/my-script
72+ patchShebangs $out/bin/my-script
73+ '';
74+}]]>
75+</programlisting>
76+77</section>
78