From ceb38a727acc903ee8fa5146c751504ace5b0b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 12 Oct 2011 14:54:20 +0000 Subject: [PATCH] doc: Write "Adding More Jobs". --- doc/manual/projects.xml | 90 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/doc/manual/projects.xml b/doc/manual/projects.xml index 7d6f64dc..cd084666 100644 --- a/doc/manual/projects.xml +++ b/doc/manual/projects.xml @@ -413,6 +413,96 @@ in tarball job, rebuilding it only if it needs to. + + +
+ Adding More Jobs + + + illustrates how to write the most + basic jobs, tarball and + build. In practice, much more can be done by + using features readily provided by Nixpkgs or by creating new jobs + as customizations of existing jobs. + + + + For instance, test coverage report for projects compiled with GCC + can be automatically generated using the + coverageAnalysis function provided by Nixpkgs + instead of nixBuild. Back to our GNU Hello + example, we can define a coverage job that + produces an HTML code coverage report directly readable from the + corresponding Hydra build page: + + + coverage = + { tarball ? jobs.tarball {} + , system ? builtins.currentSystem + }: + + let pkgs = import nixpkgs { inherit system; }; in + pkgs.releaseTools.coverageAnalysis { + name = "hello" ; + src = tarball; + configureFlags = [ "--disable-silent-rules" ]; + }; + + As can be seen, the only difference compared to + build is the use of + coverageAnalysis. + + + + Nixpkgs provides many more build tools, including the ability to + run build in virtual machines, which can themselves run another + GNU/Linux distribution, which allows for the creation of packages + for these distributions. Please see the + pkgs/build-support/release directory + of Nixpkgs for more. The NixOS manual also contains information + about whole-system testing in virtual machine. + + + + Now, assume we want to build Hello with an old version of GCC, and + with different configure flags. A new + build_exotic job can be written that simply + overrides the relevant arguments passed to + nixBuild: + + + build_exotic = + { tarball ? jobs.tarball {} + , system ? builtins.currentSystem + }: + + let + pkgs = import nixpkgs { inherit system; }; + build = jobs.build { inherit tarball system; }; + in + pkgs.lib.overrideDerivation build (attrs: { + buildInputs = [ pkgs.gcc33 ]; + preConfigure = "gcc --version"; + configureFlags = + attrs.configureFlags ++ [ "--disable-nls" ]; + }); + + The build_exotic job reuses + build and overrides some of its arguments: it + adds a dependency on GCC 3.3, a pre-configure phase that runs + gcc --version, and adds the + --disable-nls configure flags. + + + + This customization mechanism is very powerful. For instance, it + can be used to change the way Hello and all + its dependencies–including the C library and compiler used to + build it–are built. See the Nixpkgs manual for more. +
+ +