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/builtins.xml | 38 +++++++-------- doc/manual/opt-common.xml | 4 +- doc/manual/writing-nix-expressions.xml | 84 ++++++++++++++++------------------ 3 files changed, 61 insertions(+), 65 deletions(-) (limited to 'doc/manual') diff --git a/doc/manual/builtins.xml b/doc/manual/builtins.xml index c7ebcc9a3346..ce68c45bf366 100644 --- a/doc/manual/builtins.xml +++ b/doc/manual/builtins.xml @@ -43,10 +43,10 @@ is also available as builtins.derivation. Return the names of the attributes in the attribute set attrs in a sorted list. - For instance, builtins.attrNames {y = 1; x = - "foo";} evaluates to ["x" "y"]. - There is no built-in function attrValues, but - you can easily define it yourself: + For instance, builtins.attrNames { y = 1; x = "foo"; + } evaluates to [ "x" "y" ]. There is + no built-in function attrValues, but you can + easily define it yourself: attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames attrs); @@ -442,10 +442,10 @@ x: x + 456 Example: -builtins.listToAttrs [ - {name = "foo"; value = 123;} - {name = "bar"; value = 456;} -] +builtins.listToAttrs + [ { name = "foo"; value = 123; } + { name = "bar"; value = 456; } + ] evaluates to @@ -466,10 +466,10 @@ builtins.listToAttrs [ example, -map (x: "foo" + x) ["bar" "bla" "abc"] +map (x: "foo" + x) [ "bar" "bla" "abc" ] - evaluates to ["foobar" "foobla" - "fooabc"]. + evaluates to [ "foobar" "foobla" "fooabc" + ]. @@ -491,10 +491,10 @@ map (x: "foo" + x) ["bar" "bla" "abc"] a package name and version. The package name is everything up to but not including the first dash followed by a digit, and the version is everything following that dash. The result is returned - in an attribute set {name, version}. Thus, + in an attribute set { name, version }. Thus, builtins.parseDrvName "nix-0.12pre12876" - returns {name = "nix"; version = - "0.12pre12876";}. + returns { name = "nix"; version = "0.12pre12876"; + }. @@ -550,9 +550,9 @@ in config.someSetting exist in attrs. For instance, -removeAttrs { x = 1; y = 2; z = 3; } ["a" "x" "z"] +removeAttrs { x = 1; y = 2; z = 3; } [ "a" "x" "z" ] - evaluates to {y = 2;}. + evaluates to { y = 2; }. @@ -632,7 +632,7 @@ removeAttrs { x = 1; y = 2; z = 3; } ["a" "x" "z"] linkend='ex-hello-builder' /> into one file: -{stdenv, fetchurl, perl}: +{ stdenv, fetchurl, perl }: stdenv.mkDerivation { name = "hello-2.1.1"; @@ -765,12 +765,12 @@ in foo using toXML default value - (e.g., {argName ? - defaultValue}: + (e.g., { argName ? + defaultValue }: ...). With , you can also call functions that have arguments without a default value (or override a default value). 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