[Nix-dev] How to install ruby gems?

Andrew Morsillo andrew.morsillo at gmail.com
Tue Jul 8 20:31:16 CEST 2014


Awhile back I needed to do some Ruby work on nixos involving rails and lots of gems so I went with RVM since nixos does not really support rubygems/bundler in full yet. I am not sure if this configuration will still work but it might be worth a shot.

In ~/.nixpkgs/config.nix I defined a custom environment for RVM like this:
packageOverrides = pkgs : with pkgs; {
    rvmEnv = pkgs.myEnvFun {
      name = "rvm";
      buildInputs = [ stdenv which readline zlib openssl libxml2 libxslt libiconv ];
      extraCmds = ''
        unset http_proxy
        unset ftp_proxy
        export LIBXML2_DIR=${libxml2}
        export LIBXSLT_DIR=${libxslt}
        export LIBICONV_DIR=${libiconv}
        export OPENSSL_DIR=${openssl}
        export READLINE_DIR=${readline}
        bash --login
        rvm use ruby
      '';
    };
  };and then installed RVM like this:

nix-env -i env-rvm
load-env-rvm
\curl -L https://get.rvm.io | bash -s stable --autolibs=0 --auto-dotfiles
rvm reinstall 2.0.0 --autolibs=0 --with-openssl-dir=$OPENSSL_DIR --with-readline-dir=$READLINE_DIR
RVM may have changed since I have done this, so I am not sure those exact commands will work. After installing RVM like this I was able to work with gems and bundler by doing 

load-env-rvm
source ~/.rvm/scripts/rvm

I have no idea if this technique is the best way to work with RVM or if it will still work at all given the current state of nixos and RVM (it worked ~6 months ago). It would be really nice to have rubygems/bundler support in nixos instead of having to revert to stateful hacks like RVM but I have not had the time (or the skill) to look into a real solution. Hope this helps!


> From: johnw at newartisans.com
> To: nix-dev at lists.science.uu.nl
> Date: Tue, 24 Jun 2014 15:30:12 -0700
> Subject: Re: [Nix-dev] How to install ruby gems?
> 
> >>>>> Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk> writes:
> 
> > Did you manage to figure anything out? There's a Ruby program that I'd like
> > to package and use but I have no idea where to even start: I'm definitely
> > not a Ruby user! Here's what the gemspec file shows in case it's relevant:
> 
> I think we need a way to do rubyPackages, the way that we have for perl and
> python.  Any Nix+ruby users willing to do that work?
> 
> John
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140708/3e4d5e39/attachment.html 


More information about the nix-dev mailing list