From 28655693920a0701caa98d7c1fd4bf9ec374388f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 23 May 2012 00:07:49 +0200 Subject: [PATCH] doc: Update to use angle brackets and `tarball' in the same evaluation. --- doc/manual/projects.xml | 121 ++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 78 deletions(-) diff --git a/doc/manual/projects.xml b/doc/manual/projects.xml index b2479046..2d2586b0 100644 --- a/doc/manual/projects.xml +++ b/doc/manual/projects.xml @@ -184,31 +184,25 @@ system String value "i686-linux" <filename>release.nix</filename> file for GNU Hello -{ nixpkgs }: - let - pkgs = import nixpkgs {}; + pkgs = import <nixpkgs> {}; jobs = rec { tarball = - { helloSrc }: - pkgs.releaseTools.sourceTarball { name = "hello-tarball"; - src = helloSrc; + src = <hello>; buildInputs = (with pkgs; [ gettext texLive texinfo ]); }; build = - { tarball ? jobs.tarball {} - , system ? builtins.currentSystem - }: + { system ? builtins.currentSystem }: - let pkgs = import nixpkgs { inherit system; }; in + let pkgs = import <nixpkgs> { inherit system; }; in pkgs.releaseTools.nixBuild { name = "hello"; - src = tarball; + src = jobs.tarball; configureFlags = [ "--disable-silent-rules" ]; }; }; @@ -244,29 +238,20 @@ in - - - This specifies a function of one named arguments, - nixpkgs. This function and those - defined below is called by Hydra. Here the - nixpkgs argument is meant to be a - checkout of the Nixpkgs - software distribution. - - - Hydra inspects the formal argument list of the function - (here, the nixpkgs argument) and passes - it the corresponding parameter specified as a build input - on Hydra's web interface. In this case, the web interface - should show a nixpkgs build input, - which is a checkout of the Nixpkgs source code repository. - - This defines a variable pkgs holding - the set of packages provided by Nixpkgs. + the set of packages provided by Nixpkgs. + + + Since nixpkgs appears in angle brackets, + there must be a build input of that name in the Nix search + path. In this case, the web interface should show a + nixpkgs build input, which is a checkout + of the Nixpkgs source code repository; Hydra then adds this + and other build inputs to the Nix search path when + evaluating release.nix. @@ -286,10 +271,11 @@ in - The tarball takes an additional - argument called helloSrc. Again, this - argument is passed by Hydra and is meant to be a checkout - of GNU Hello's source code repository. + The tarball jobs expects a + hello build input to be available in the + Nix search path. Again, this input is passed by Hydra and + is meant to be a checkout of GNU Hello's source code + repository. @@ -320,25 +306,25 @@ in - The build function takes two additional - parameter: tarball, which is meant to - be the result of the tarball job, and - system, which should be a string + The build function takes one + parameter, system, which should be a string defining the Nix system type–e.g., - "x86_64-linux". + "x86_64-linux". Additionally, it refers + to jobs.tarball, seen above. - Again, these parameters are passed by Hydra when it calls - build. Thus, they must be defined as - build inputs in Hydra: tarball should - have type Build Output, its value being - the latest output of the tarball job, - and system should be a string. + Hydra inspects the formal argument list of the function + (here, the system argument) and passes it + the corresponding parameter specified as a build input on + Hydra's web interface. Here, system is + passed by Hydra when it calls build. + Thus, it must be defined as a build input of type string in + Hydra, which could take one of several values. - The question mark after tarball and - system defines default values for these - arguments, and is only useful for debugging. + The question mark after system defines + the default value for this argument, and is only useful when + debugging locally. @@ -383,29 +369,12 @@ $ nix-build release.nix -A tarball probably yield an error like this: -error: cannot auto-call a function that has an argument without a default value (`nixpkgs') +error: user-thrown exception: file `hello' was not found in the Nix search path (add it using $NIX_PATH or -I) - This is because no value was specified for the - nixpkgs argument of the Nix expression. - - - - This is fixed by providing a default value for that argument in - the Nix expression, which will allow nix-build - to auto-call the function: instfead of writing { nixpkgs - }:, we now write { nixpkgs ? <nixpkgs> - }:. What it means is that, by default, the - nixpkgs variable will be bound to the absolute - path of any nixpkgs file found in the Nix - search path. Similarly, a default value for - helloSrc needs to be provided. - - - - Thus, assuming a checkout of Nixpkgs is available under - $HOME/src/nixpkgs, the - tarball jobset can now be evaluated by running: + The error is self-explanatory. Assuming + $HOME/src/hello points to a checkout of + Hello, this can be fixed this way: $ nix-build -I ~/src release.nix -A tarball @@ -445,14 +414,12 @@ $ nix-build -I ~/src release.nix -A build coverage = - { tarball ? jobs.tarball {} - , system ? builtins.currentSystem - }: + { system ? builtins.currentSystem }: let pkgs = import nixpkgs { inherit system; }; in pkgs.releaseTools.coverageAnalysis { name = "hello"; - src = tarball; + src = jobs.tarball; configureFlags = [ "--disable-silent-rules" ]; }; @@ -482,13 +449,11 @@ coverage = build_exotic = - { tarball ? jobs.tarball {} - , system ? builtins.currentSystem - }: + { system ? builtins.currentSystem }: let pkgs = import nixpkgs { inherit system; }; - build = jobs.build { inherit tarball system; }; + build = jobs.build { inherit system; }; in pkgs.lib.overrideDerivation build (attrs: { buildInputs = [ pkgs.gcc33 ];