[Nix-dev] Re: Ruby-gems

Bárður Árantsson spam at scientician.net
Sun Aug 3 20:34:16 CEST 2008


Pjotr Prins wrote:
>> I don't know if setting search paths and environment variables and all
>> is possible with Ruby gems. Is there any easy documentation about it?
> 
> 'gem help install' gives quite a few options - including --bindir and
> --install-dir.
> 
>> In the past we have used wrapper packages for this. It would work a bit
>> like this (but I don't know how it would impact Ruby things):
>>
>> 1 install a package with Nix
>> 2 install addons
>> 3 create an expression, which takes 1 and 2 as input and creates a
>> wrapper package, that combines the two packages, using environment
>> variables, search paths, and so on
> 
> That works if you know the package beforehand. I think we have to
> deal with 'addons' users want to install later. Most high-level
> languages support this type of system: python eggs, ruby gems, perl
> cpan, R modules etc. etc. By default they will install in /nix/store
> where the language interpreter is installed. This causes problems.
> 
> I think the right thing to do is modify these package managers to
> support Nix. 
> 
> The only other option is to allow 'addons' outside the store - as a
> normal user would do under $HOME. However, how do we handle system
> wide packages.
> 
> One policy would be to say:
> 
> - system wide: Use a Nix package
> - user:        Under $HOME
> 
> That is the lazy option ;-).
> 
> My problem is that I want to provide Ruby to biologists, and can not
> support all GEMs they will think of.
> 

I had a similar problem with the bzrtools package which essentially 
needs to install "into" a different pacakge (bzr) in a similar way.

Just wondering out loud here, but... as far as I can tell this could be 
fixed quite easily if there were a standard way for packages to augment 
the user's environment variables (or the system environment variables if 
you want system-wide installation). In the case of bzrtools the problem 
could easily be solved by letting the bzrtools package install wherever 
it wants and augmenting the PYTHONPATH variable with its location.

So, for example:

   1) user installs bzrtools
   2) nix augments the user's environment, effectively setting
          PYTHONPATH=/nix/store/<hash>-bzrtools/path/to/files:$PYTHONPATH
      because this is specified in the bzrtools package "recipe".
   3) user proceeds to happily use bzrtools :)

I'm not familiar enough with Nix to really know how much machinery it 
would take to pull this off, but I'm imagning a simple mechanism like
an automatically built shell script in the user's .nix-profile (or in 
the system profile) which the user's .xsession/.bashrc or whatever can
source.

I'm not too familiar with the ruby, but I imagine that e.g. ruby has a 
PATH variable which could be used similarly...?

(Users who really want to install some packages on their own should 
still be fine as all the dependencies should be found by 
python/ruby/etc. as long as the search path is augmented.)

Cheers,

-- 
Bardur Arantsson
<bardurREMOVE at THISscientician.net>

- I'm sorry I lied to you, Marge, but this gun had a hold on me.
I felt this incredible surge of power, like God must feel when
he's holding a gun.
                                     Homer Simpson, 'The Simpsons'




More information about the nix-dev mailing list