summary refs log tree commit diff
path: root/doc/languages-frameworks/ruby.xml
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-01-21 13:07:56 +0300
committerNikolay Amiantov <ab@fmap.me>2016-01-21 13:10:09 +0300
commita98dfaa6b96a00b6822f25ca7638d4ae7d57a855 (patch)
tree11903e7ec83f29f5f5cffca43813f780e4b8fdf8 /doc/languages-frameworks/ruby.xml
parent75358ad0e7a143ad6849882a1967ef6a5c2e6e68 (diff)
downloadnixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.tar
nixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.tar.gz
nixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.tar.bz2
nixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.tar.lz
nixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.tar.xz
nixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.tar.zst
nixpkgs-a98dfaa6b96a00b6822f25ca7638d4ae7d57a855.zip
nix manual: add bundlerEnv.env and .wrapper items descriptions
Diffstat (limited to 'doc/languages-frameworks/ruby.xml')
-rw-r--r--doc/languages-frameworks/ruby.xml32
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/languages-frameworks/ruby.xml b/doc/languages-frameworks/ruby.xml
index a2b4475a4a5..d81422b610e 100644
--- a/doc/languages-frameworks/ruby.xml
+++ b/doc/languages-frameworks/ruby.xml
@@ -42,5 +42,37 @@ and scalable.";
 <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.
 </para>
 
+<para>Resulting derivations also have two helpful items, <literal>env</literal> and <literal>wrapper</literal>. The first one allows one to quickly drop into
+<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
+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
+<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.
+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
+run <command>bundix</command> as specified above and then use <literal>bundlerEnv</literal> lile this:</para>
+
+<programlisting>
+<![CDATA[let env = bundlerEnv {
+  name = "my-script-env";
+
+  inherit ruby;
+  gemfile = ./Gemfile;
+  lockfile = ./Gemfile.lock;
+  gemset = ./gemset.nix;
+};
+
+in stdenv.mkDerivation {
+  name = "my-script";
+
+  buildInputs = [ env.wrapper ];
+
+  script = ./my-script.rb;
+
+  buildCommand = ''
+    mkdir -p $out/bin
+    install -D -m755 $script $out/bin/my-script
+    patchShebangs $out/bin/my-script
+  '';
+}]]>
+</programlisting>
+
 </section>