···4242<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.
4343</para>
44444545+<para>Resulting derivations also have two helpful items, <literal>env</literal> and <literal>wrapper</literal>. The first one allows one to quickly drop into
4646+<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
4747+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
4848+<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.
4949+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
5050+run <command>bundix</command> as specified above and then use <literal>bundlerEnv</literal> lile this:</para>
5151+5252+<programlisting>
5353+<![CDATA[let env = bundlerEnv {
5454+ name = "my-script-env";
5555+5656+ inherit ruby;
5757+ gemfile = ./Gemfile;
5858+ lockfile = ./Gemfile.lock;
5959+ gemset = ./gemset.nix;
6060+};
6161+6262+in stdenv.mkDerivation {
6363+ name = "my-script";
6464+6565+ buildInputs = [ env.wrapper ];
6666+6767+ script = ./my-script.rb;
6868+6969+ buildCommand = ''
7070+ mkdir -p $out/bin
7171+ install -D -m755 $script $out/bin/my-script
7272+ patchShebangs $out/bin/my-script
7373+ '';
7474+}]]>
7575+</programlisting>
7676+4577</section>
4678