Building Genode with Nix

Emery Hemingway emery at ...261...
Tue Aug 12 18:40:45 CEST 2014


In what started as an effort to fix some simple problems when building
Genode on NixOS, I have gone ahead and attempted to replace the Make
build system with one implemented in Nix.

For those not familiar with Nix there is a brief overview here, but what
I have done falls outside the scope of package management.
http://nixos.org/nix/about.html

The theory behind Nix is explained in detail here.
http://dspace.library.uu.nl/handle/1874/7540


To start out with, here are some problems with a Nix build system:

 * Nix must be ported to Genode if Genode shall be self hosting.
 * Each Make target will probably have to be re-expressed in Nix.
 * Nix produces more arcane output than Make.


Some benefits as I see it:

 * Nix is the only build system dependency.
 * More build parallelism.
 * Lazy dependency evaluation means faster rebuilding.
 * Binary component packages.
 * NixOS can be nested in the Genode build system.
 * Genode can be nested in the NixOS build system.
 * Less boilerplate.
 * Less user interaction.


That said, my conversion is far from complete, my focus has been on
getting the Linux and Nova implemenations working. I have core and init
building for Linux and Nova as well as a number of tests. The Expect
framework for executing Genode has been wrapped and works for Linux, but
I will have to express the Nova kernel before moving on to Qemu support.
I've been bypassing ARM to avoid getting into the details of the spec
managment for now.


If anyone would like to try it out I'm working on the 'nix' branch at
https://github.com/ehmry/genode.git

The only depency is Nix which you can get here: http://nixos.org/nix/

There is a script named 'try_me.sh' that will run the tests that have
been defined.

If you wish to explore further the command that you will need to get
aquainted with is 'nix-build'. For example, to build some components:
  nix-build ~/genode/specs/x86_64-nova.nix -A base.core
  nix-build ~/genode/specs/x86_64-nova.nix -A os.tests
  nix-build ~/genode/specs/x86_64-linux.nix -A run.thread

Nix-build will leave a symlink named 'result' in your current directory
that contains the output of the Nix expression you call.

To remove the outputs that Nix has built, delete the result symlink and
run 'nix-store -gc' to invoke the garbarge collector.


If you first want to know what Nix will do when building a run from
scratch, here is a summary:
 
  Install dependencies for the Nix build environment, Nix will likely
  not use anything in your current PATH.

  Download and patch the Genode toolchain for the Genode build environment.

  Compile the sources of each dependency into object files.

  Merge objects into libraries.

  Link libraries into applications.

  Execute Genode and leave the build output and a log of the run in
  a directory in the Nix store.

If there are any questions I will be lurking as 'emery' in the IRC
channel on Freenode.



As some of us like to say over here, "If it ain't broke, you're not trying."

Emery Hemingway




More information about the users mailing list