From 93e71e6ab68d9662441289a02448c47069beeb2a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 30 Dec 2011 17:39:03 +0000 Subject: * Follow our own coding conventions. --- doc/manual/writing-nix-expressions.xml | 84 ++++++++++++++++------------------ 1 file changed, 40 insertions(+), 44 deletions(-) (limited to 'doc/manual/writing-nix-expressions.xml') diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index 58b5a1ed023e..e16225433dea 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -52,7 +52,7 @@ need to do three things: Nix expression for GNU Hello (<filename>default.nix</filename>) -{stdenv, fetchurl, perl}: +{ stdenv, fetchurl, perl }: stdenv.mkDerivation { name = "hello-2.1.1"; @@ -92,8 +92,8 @@ the single Nix expression in that directory function that downloads files. perl is the Perl interpreter. - Nix functions generally have the form {x, y, ..., - z}: e where x, y, + Nix functions generally have the form { x, y, ..., + z }: e where x, y, etc. are the names of the expected arguments, and where e is the body of the function. So here, the entire remainder of the file is the body of the @@ -114,10 +114,10 @@ the single Nix expression in that directory attributes. An attribute set is just a list of key/value pairs where each value is an arbitrary Nix expression. They take the general form - {name1 = + { name1 = expr1; ... nameN = - exprN;}. + exprN; }. @@ -564,7 +564,7 @@ genericBuild expression, like this: - buildInputs = [perl]; + buildInputs = [ perl ]; The perl attribute can then be removed, and the builder becomes even shorter: @@ -771,14 +771,14 @@ stdenv.mkDerivation { values between square brackets. For example, -[ 123 ./foo.nix "abc" (f {x=y;}) ] +[ 123 ./foo.nix "abc" (f { x = y; }) ] defines a list of four elements, the last being the result of a call to the function f. Note that function calls have to be enclosed in parentheses. If they had been omitted, e.g., -[ 123 ./foo.nix "abc" f {x=y;} ] +[ 123 ./foo.nix "abc" f { x = y; } ] the result would be a list of five elements, the fourth one being a function and the fifth being an attribute set. @@ -891,15 +891,12 @@ propagate attributes). This can be shortened using the inherit keyword. For instance, -let - x = 123; -in - { - inherit x; - y = 456; - } - -evaluates to {x = 123; y = 456;}. (Note that this +let x = 123; in +{ inherit x; + y = 456; +} + +evaluates to { x = 123; y = 456; }. (Note that this works because x is added to the lexical scope by the let construct.) It is also possible to inherit attributes from another attribute set. For instance, in this fragment @@ -960,20 +957,20 @@ in if negate true then concat "foo" "bar" else "" arguments of a function); e.g., -map (concat "foo") ["bar" "bla" "abc"] +map (concat "foo") [ "bar" "bla" "abc" ] - evaluates to ["foobar" "foobla" - "fooabc"]. + evaluates to [ "foobar" "foobla" + "fooabc" ]. An attribute set pattern of the - form {name1, name2, …, nameN} + form { name1, name2, …, nameN } matches an attribute set containing the listed attributes, and binds the values of those attributes to variables in the function body. For example, the function -{x, y, z}: z + y + x +{ x, y, z }: z + y + x can only be called with a set containing exactly the attributes x, y and @@ -982,7 +979,7 @@ map (concat "foo") ["bar" "bla" "abc"] (...): -{x, y, z, ...}: z + y + x +{ x, y, z, ... }: z + y + x This works on any set that contains at least the three named attributes. @@ -995,7 +992,7 @@ map (concat "foo") ["bar" "bla" "abc"] e is an arbitrary expression. For example, -{x, y ? "foo", z ? "bar"}: z + y + x +{ x, y ? "foo", z ? "bar" }: z + y + x specifies a function that only requires an attribute named x, but optionally accepts y @@ -1007,11 +1004,11 @@ map (concat "foo") ["bar" "bla" "abc"] of the @-sign. For example: -args@{x, y, z, ...}: z + y + x + args.a +args@{ x, y, z, ... }: z + y + x + args.a Here args is bound to the entire argument, which - is further matches against the pattern {x, y, z, - ...}. + is further matches against the pattern { x, y, z, + ... }. @@ -1020,8 +1017,8 @@ args@{x, y, z, ...}: z + y + x + args.a a name, you can bind them to an attribute, e.g., -let concat = {x, y}: x + y; -in concat {x = "foo"; y = "bar";} +let concat = { x, y }: x + y; +in concat { x = "foo"; y = "bar"; } @@ -1142,7 +1139,7 @@ lexical scope of the expression e2. For instance, -let as = {x = "foo"; y = "bar";}; +let as = { x = "foo"; y = "bar"; }; in with as; x + y evaluates to "foobar" since the @@ -1480,21 +1477,20 @@ allowedReferences = []; references graph of their inputs. The attribute is a list of inputs in the Nix store whose references graph the builder needs to know. The value of this attribute should be a list of pairs - [name1 + [ name1 path1 name2 - path2 - ...]. The references graph - of each pathN will be stored in a text - file nameN in the temporary build - directory. The text files have the format used by - nix-store --register-validity (with the deriver - fields left empty). For example, when the following derivation is - built: + path2 ... + ]. The references graph of each + pathN will be stored in a text file + nameN in the temporary build directory. + The text files have the format used by nix-store + --register-validity (with the deriver fields left + empty). For example, when the following derivation is built: derivation { ... - exportReferencesGraph = ["libfoo-graph" libfoo]; + exportReferencesGraph = [ "libfoo-graph" libfoo ]; }; @@ -1571,14 +1567,14 @@ fetchurl { fetchurl: -{stdenv, curl}: # The curl program is used for downloading. +{ stdenv, curl }: # The curl program is used for downloading. -{url, md5}: +{ url, md5 }: stdenv.mkDerivation { name = baseNameOf (toString url); builder = ./builder.sh; - buildInputs = [curl]; + buildInputs = [ curl ]; # This is a fixed-output derivation; the output must be a regular # file with MD5 hash md5. @@ -1650,7 +1646,7 @@ stdenv.mkDerivation { Nixpkgs has the line -impureEnvVars = ["http_proxy" "https_proxy" ...]; +impureEnvVars = [ "http_proxy" "https_proxy" ... ]; to make it use the proxy server configuration specified by the -- cgit 1.4.1