diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index b6f426d663..99d766872f 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -447,7 +447,7 @@ following: (import pkgs/system/i686-linux.nix).hello -Call it test.nix. Then you can build it without +Call it test.nix. You can then build it without installing it using the command nix-build: @@ -501,7 +501,86 @@ run in parallel. Typically this should be the number of CPUs. The generic builder -TODO +Recall from that the builder +looked something like this: + + +PATH=$perl/bin:$PATH +tar xvfz $src +cd hello-* +./configure --prefix=$out +make +make install + +The builders for almost all Unix packages look like this — set up some +environment variables, unpack the sources, configure, build, and +install. For this reason the standard environment provides some Bash +functions that automate the build process. A builder using the +generic build facilities in shown in . + +Build script using the generic +build functions + +buildInputs="$perl" + +. $stdenv/setup + +genericBuild + + + + + + + The buildInputs variable tells + setup to use the indicated components as + inputs. This means that if a component provides a + bin subdirectory, it's added to + PATH; if it has a include + subdirectory, it's added to GCC's header search path; and so + on. + + + + + + The function genericBuild is defined in + the file $stdenv/setup. + + + + + + The final step calls the shell function + genericBuild, which performs the steps that + were done explicitly in . The + generic builder is smart enough to figure out whether to unpack + the sources using gzip, + bzip2, etc. It can be customised in many ways; + see . + + + + + +Discerning readers will note that the +buildInputs could just as well have been set in the Nix +expression, like this: + + + buildInputs = [perl]; + +The perl attribute can then be removed, and the +builder becomes even shorter: + + +. $stdenv/setup +genericBuilder> + +In fact, mkDerivation provides a default builder +that looks exactly like that, so it is actually possible to omit the +builder for Hello entirely. @@ -661,7 +740,7 @@ shortened using the inherit keyword. For instance, --> -Lets +Let expressions TODO @@ -691,7 +770,7 @@ shortened using the inherit keyword. For instance, -<quote>With</quote> expressions +With expressions TODO @@ -723,7 +802,7 @@ shortened using the inherit keyword. For instance, -The standard environment +The standard environment TODO