Nix, NixOS and Ruby Gems
March 3rd, 2009

Last summer, I discovered a unique software packaging and build system called Nix from Utrecht University in the Netherlands.
Building and packaging software has been my primary work activity for the past 10 years. I have maintained hundreds of RPMs and Debian packages, and have managed some very large code repositories, toolchains and build farms. It’s been fun, but I do have to admit that being a “package monkey” is not the most glamourous of software development activities.
With all that experience, I feel that I have a developed a strong appreciation for nice software plumbing. The Nix project really excites me. There are two things it does differently that make it stand out:
-
Strange filesystem layout using cryptographic hashes
In Nix, each software package is stored in it’s own directory, under /nix/store/<cryptographic-hash>-<name>, instead of in the conventional Unix locations such as /usr/bin, /usr/lib, /usr/include, etc.
With this scheme, it becomes possible to simultaneously install and run multiple variations of the same piece of software, including dependencies. In fact, it would even be possible to have every computer in the world share the same filesystem, even though if they were all running different software!
-
Completely functional / declarative description of complete software systems
Nix has a language that enables you to completely describe the running state of an entire set of software in a declarative way. You just tell it what you want — then it takes care of building it, distributing it and even starting it up and running it!
It can be used as a companion software management system on Mac OS X (similar to MacPorts or Fink), Windows (using Cygwin), or on any Linux distribution. There is also a companion project called NixOS which is a full Linux distribution built entirely using Nix.
I highly recommend looking at it. Keep in mind that it is definitely not mainstream, and there are not a lot of users yet. It is not a friendly system for traditional Unix system administrators, who are accustomed to finding their files in predictable locations in the filesystem. Systems are managed by writing expressions in the Nix language, which only has a small amount of documentation and not a lot of friendly examples.
I have done a bit of work adapting NixOS so I could get it to run inside a Xen session on my server. I am also using Nix successfully on OS X, as well as with VirtualBox, and on Debian on Amazon’s EC2.
Currently, I am working on some Nix expressions to make it easy to deploy software based on Ruby Gems (such as Rails, Merb, Rack and Sinatra) on top of Nix. You can read about my initial experiments in this post to the nix-dev mailing list. So far, I’m pleased with the results. I expect to package up a few more gems soon, and I will be using this system in production for some upcoming demos I am planning.

Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed