[Nix-dev] Packaging Foreman

Alex Berg chexxor at gmail.com
Fri Nov 22 05:39:16 CET 2013


I've hit another wall. Foreman wants to use an app called Facter, which is
part of the Puppet application. So, I am now trying to package Puppet and
Facter. Right now I'm trying to package Facter.

The install process for Facter seems pretty simple: unpack the tarball and
then run `install.rb`. When I run the installer, I get an error, which says
the Nix Store is read-only:

    $ ruby install.rb --destdir=$out #--sitelibdir=$out/lib
--bindir=$out/bin
    which: no rst2man.py in (`echo $PATH`)

/nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/lib/ruby/1.9.1/fileutils.rb:247:in
`mkdir': Read-only file system -
/nix/store/57s9s4i9a8iqa726qa6hksj5glf9qcjz-facter/nix/store/57s9s4i9a8iqa726qa6hksj5glf9qcjz-facter
(Errno::EROFS)

It looks like the Nix store directory of the `facter` package is read-only,
which makes sense. But, this is the Facter installer that is running! It
needs write access to its installation directory, no?


Another question, about Ruby. Where should Ruby's "site" and "vendor"
libraries be installed? This page from 2008 [1] says that "vendor_lib"
should be used by package managers, and "site_lib" should be used by users,
to avoid overwriting a user's local/custom libraries. I can't find it now,
but I believe Debian or Fedora have a "/usr/lib/ruby/site_lib/" directory
for this, which is a global dump for these.

Please correct me if I'm wrong here, because I'm still not a Ruby pro. I
believe the only place to store these is inside a derivation in the Nix
store. In this case, Facter's Ruby libs should be stored in
"<facter-nix-path>/lib". But, then we have to adjust the "GEM_PATH"
environment variable to include these when executing Ruby scripts. Is this
the right idea?


[1] http://www.rubyinside.com/ruby-187-released-912.html




On Tue, Nov 19, 2013 at 6:03 PM, Alex Berg <chexxor at gmail.com> wrote:

> Awesome, that's exactly the info I needed. I added those as dependencies
> and now I'm making progress again. Now I'm working through a Ruby issue
> "(Gem::RemoteFetcher::FetchError)".
>
> For curious readers, here's how I did that.
>
> ### foreman/default.nix ###
> { stdenv, fetchurl, rubygems, gcc, git, libvirt, mysql,
>   postgresql, openssl, libxml2, sqlite, libxslt, zlib, readline
> }:
>
> stdenv.mkDerivation rec {
>
>   name = "foreman";
>
>   src = fetchurl {
>     # Tarball link fetched from here:
> http://projects.theforeman.org/projects/foreman/files
>     url = "
> http://projects.theforeman.org/attachments/download/642/foreman-1.3.1.tar.bz2
> ";
>     sha256 = "0jq48nswwgx7lk79cpdm2zmn40rxf1jjnng63qmam09m4pbypj3r";
>   };
>
>   buildInputs = [ rubygems gcc git libvirt mysql
>   postgresql openssl libxml2 sqlite libxslt zlib readline ];
> ...
>
>
>  On Tue, Nov 19, 2013 at 5:17 PM, Oliver Charles <ollie at ocharles.org.uk>wrote:
>
>>  On 11/19/2013 09:03 AM, Alex Berg wrote:
>> >
>> > As part of the Heroku Toolbelt, I need to make a Nix package for
>> > Foreman. I am following the instructions to Install from Source [1]. The
>> > instructions say that it has many package requirements:
>> >
>> >     gcc-c++ git libvirt-devel mysql-devel pg-devel openssl-devel \
>> >         libxml2-devel sqlite-devel libxslt-devel zlib-devel
>> readline-devel \
>> >         postgresql-devel
>> >
>> > Am I right when I say - If I want to package Foreman, I must first
>> > package all these dependent packages. ?
>>
>> I don't know Foreman, but yes - you will need all of those dependencies.
>> Note however that these dependencies seem to be specified as Ubuntu
>> package names. We don't strip out include files from our packages, so we
>> don't have 'devel' versions. Thus a lot of these dependencies we
>> probably already have:
>>
>> gcc-c++ -> gcc
>> mysql-devel -> mysql
>> pg-devel -> postgresql9*
>> sqlite-devel -> sqlite
>>
>> etc.
>>
>> I tend to grep in <nixpkgs>/pkgs/top-level/all-packages.nix for the
>> start of the expression, find something that looks relevant, add it to
>> the expression of whatever I'm packaging, and attempt to nix-build. I
>> repeat that process until all dependencies are satisfied
>>
>> > Related question: Does anyone know how to use the auto-generated Gem
>> > packages? I can't find any docs. -
>> >
>> https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/ruby/generated.nix
>>
>> This really needs better documentation. Most people will tell you to
>> read <nixpkgs>/pkgs/development/interpreters/ruby/rubygems.nix, but imo
>> that is not good enough.
>>
>> - ocharles
>>
>>
>> _______________________________________________
>> 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/20131122/5331101a/attachment.html 


More information about the nix-dev mailing list