diff options
Diffstat (limited to 'doc/manual/src/language')
-rw-r--r-- | doc/manual/src/language/constructs.md | 28 | ||||
-rw-r--r-- | doc/manual/src/language/derivations.md | 38 | ||||
-rw-r--r-- | doc/manual/src/language/operators.md | 1 |
3 files changed, 33 insertions, 34 deletions
diff --git a/doc/manual/src/language/constructs.md b/doc/manual/src/language/constructs.md index a3590f55d..2a527770a 100644 --- a/doc/manual/src/language/constructs.md +++ b/doc/manual/src/language/constructs.md @@ -146,65 +146,65 @@ three kinds of patterns: - If a pattern is a single identifier, then the function matches any argument. Example: - + ```nix let negate = x: !x; concat = x: y: x + y; in if negate true then concat "foo" "bar" else "" ``` - + Note that `concat` is a function that takes one argument and returns a function that takes another argument. This allows partial parameterisation (i.e., only filling some of the arguments of a function); e.g., - + ```nix map (concat "foo") [ "bar" "bla" "abc" ] ``` - + evaluates to `[ "foobar" "foobla" "fooabc" ]`. - A *set pattern* of the form `{ name1, name2, …, nameN }` matches a set containing the listed attributes, and binds the values of those attributes to variables in the function body. For example, the function - + ```nix { x, y, z }: z + y + x ``` - + can only be called with a set containing exactly the attributes `x`, `y` and `z`. No other attributes are allowed. If you want to allow additional arguments, you can use an ellipsis (`...`): - + ```nix { x, y, z, ... }: z + y + x ``` - + This works on any set that contains at least the three named attributes. - + It is possible to provide *default values* for attributes, in which case they are allowed to be missing. A default value is specified by writing `name ? e`, where *e* is an arbitrary expression. For example, - + ```nix { x, y ? "foo", z ? "bar" }: z + y + x ``` - + specifies a function that only requires an attribute named `x`, but optionally accepts `y` and `z`. - An `@`-pattern provides a means of referring to the whole value being matched: - + ```nix args@{ x, y, z, ... }: z + y + x + args.a ``` - + but can also be written as: - + ```nix { x, y, z, ... } @ args: z + y + x + args.a ``` diff --git a/doc/manual/src/language/derivations.md b/doc/manual/src/language/derivations.md index e4a2fe714..1dceacab7 100644 --- a/doc/manual/src/language/derivations.md +++ b/doc/manual/src/language/derivations.md @@ -24,22 +24,22 @@ the attributes of which specify the inputs of the build. - Every attribute is passed as an environment variable to the builder. Attribute values are translated to environment variables as follows: - + - Strings and numbers are just passed verbatim. - + - A *path* (e.g., `../foo/sources.tar`) causes the referenced file to be copied to the store; its location in the store is put in the environment variable. The idea is that all sources should reside in the Nix store, since all inputs to a derivation should reside in the Nix store. - + - A *derivation* causes that derivation to be built prior to the present derivation; its default output path is put in the environment variable. - + - Lists of the previous types are also allowed. They are simply concatenated, separated by spaces. - + - `true` is passed as the string `1`, `false` and `null` are passed as an empty string. @@ -56,36 +56,36 @@ the attributes of which specify the inputs of the build. library doesn’t need the header files and documentation at runtime, and it doesn’t need the documentation at build time. Thus, the library package could specify: - + ```nix outputs = [ "lib" "headers" "doc" ]; ``` - + This will cause Nix to pass environment variables `lib`, `headers` and `doc` to the builder containing the intended store paths of each output. The builder would typically do something like - + ```bash ./configure \ --libdir=$lib/lib \ --includedir=$headers/include \ --docdir=$doc/share/doc ``` - + for an Autoconf-style package. You can refer to each output of a derivation by selecting it as an attribute, e.g. - + ```nix buildInputs = [ pkg.lib pkg.headers ]; ``` - + The first element of `outputs` determines the *default output*. Thus, you could also write - + ```nix buildInputs = [ pkg pkg.headers ]; ``` - + since `pkg` is equivalent to `pkg.lib`. The function `mkDerivation` in the Nixpkgs standard environment is a @@ -103,24 +103,24 @@ The builder is executed as follows: specified above. - In addition, the following variables are set: - + - `NIX_BUILD_TOP` contains the path of the temporary directory for this build. - + - Also, `TMPDIR`, `TEMPDIR`, `TMP`, `TEMP` are set to point to the temporary directory. This is to prevent the builder from accidentally writing temporary files anywhere else. Doing so might cause interference by other processes. - + - `PATH` is set to `/path-not-set` to prevent shells from initialising it to their built-in default value. - + - `HOME` is set to `/homeless-shelter` to prevent programs from using `/etc/passwd` or the like to find the user's home directory, which could cause impurity. Usually, when `HOME` is set, it is used as the location of the home directory, even if it points to a non-existent path. - + - `NIX_STORE` is set to the path of the top-level Nix store directory (typically, `/nix/store`). @@ -128,7 +128,7 @@ The builder is executed as follows: is set to `true` for the dervation. A detailed explanation of this behavior can be found in the [section about structured attrs](./advanced-attributes.md#adv-attr-structuredAttrs). - + - For each output declared in `outputs`, the corresponding environment variable is set to point to the intended path in the Nix store for that output. Each output path is a concatenation diff --git a/doc/manual/src/language/operators.md b/doc/manual/src/language/operators.md index f8382ae19..418d0349f 100644 --- a/doc/manual/src/language/operators.md +++ b/doc/manual/src/language/operators.md @@ -161,4 +161,3 @@ All comparison operators are implemented in terms of `<`, and the following equi Equivalent to `!`*b1* `||` *b2*. [Logical implication]: #logical-implication - |