[Nix-dev] Announcing New Ruby Support

Charles Strahan charles.c.strahan at gmail.com
Thu Jan 22 05:29:55 CET 2015


Hello all,

I'm pleased to announce that the Pleasant Ruby PR has landed on master. The
new
feature - bundlerEnv - allows one to package Ruby applications with Bundler.

To use the new system, first create (or copy over) a Gemfile describing the
required gems.

Next, create a Gemfile.lock by running `bundler package --no-install` in the
containing directory (this also creates two folders - vendor and .bundle -
which you'll want to delete before committing).

Now, you'll need to dump the lockfile as a Nix expression. To do so, use
Bundix
in the target directory:

  $(nix-build '<nixpkgs>' -A bundix)/bin/bundix

That will drop a gemset.nix file in your current directory, which describes
the
sources for all of the gems and their respective SHAs.

Finally, you'll need to use bundlerEnv to build the gems. The following
example
is how we package the sup mail reader:

  { stdenv, lib, bundlerEnv, gpgme, ruby, ncurses, writeText, zlib, xapian
  , pkgconfig, which }:

  bundlerEnv {
    name = "sup-0.20.0";

    inherit ruby;
    gemfile = ./Gemfile;
    lockfile = ./Gemfile.lock;
    gemset = ./gemset.nix;

    # This is implicit:
    #
    #   gemConfig = defaultGemConfig;
    #
    # You could just as well do the following:
    #
    #   gemConfig.ncursesw = spec: {
    #     buildInputs = [ ncurses ];
    #     buildFlags = [
    #       "--with-cflags=-I${ncurses}/include"
    #       "--with-ldflags=-L${ncurses}/lib"
    #     ];
    #   };
    #
    # Where `spec` is the attributes of the corresponding gem,
    # in case you wanted to make something predicated on version,
    # for example.
    #
    # See default-gem-config.nix for more examples.

    meta = with lib; {
      description = "A curses threads-with-tags style email client";
      homepage    = http://supmua.org;
      license     = with licenses; gpl2;
      maintainers = with maintainers; [ cstrahan lovek323 ];
      platforms   = platforms.unix;
    };
  }

And that's all there is to it!

Enjoy,

-Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150121/6cd73e96/attachment.html 


More information about the nix-dev mailing list