From 5bc41d78ffcd2952eaddb20ef129f48e94d60cb0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Oct 2013 16:41:04 +0200 Subject: Rename "attribute sets" to "sets" We don't have any other kind of sets so calling them attribute sets is unnecessarily verbose. --- doc/manual/builtins.xml | 82 ++++++++++++------------- doc/manual/nix-env.xml | 11 ++-- doc/manual/writing-nix-expressions.xml | 106 ++++++++++++++++----------------- 3 files changed, 99 insertions(+), 100 deletions(-) (limited to 'doc') diff --git a/doc/manual/builtins.xml b/doc/manual/builtins.xml index ce21e8525006..42fcd70eb1af 100644 --- a/doc/manual/builtins.xml +++ b/doc/manual/builtins.xml @@ -12,9 +12,9 @@ such as derivation, are always in scope of every Nix expression; you can just access them right away. But to prevent polluting the namespace too much, most built-ins are not in scope. Instead, you can access them through the builtins -built-in value, which is an attribute set that contains all built-in -functions and values. For instance, derivation -is also available as builtins.derivation. +built-in value, which is a set that contains all built-in functions +and values. For instance, derivation is also +available as builtins.derivation. @@ -39,14 +39,14 @@ is also available as builtins.derivation. builtins.attrNames - attrs + set - 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: + Return the names of the attributes in the set + set 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: attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames attrs); @@ -68,8 +68,8 @@ attrValues = attrs: map (name: builtins.getAttr name attrs) (builtins.attrNames builtins - The attribute set builtins - contains all the built-in functions and values. You can use + The set builtins contains all + the built-in functions and values. You can use builtins to test for the availability of features in the Nix installation, e.g., @@ -258,11 +258,11 @@ stdenv.mkDerivation { builtins.getAttr - s attrs + s set getAttr returns the attribute - named s from the attribute set - attrs. Evaluation aborts if the + named s from + set. Evaluation aborts if the attribute doesn’t exist. This is a dynamic version of the . operator, since s is an expression rather than an identifier. @@ -289,15 +289,15 @@ stdenv.mkDerivation { builtins.hasAttr - s attrs + s set hasAttr returns - true if the attribute set - attrs has an attribute named - s, and false - otherwise. This is a dynamic version of the ? - operator, since s is an expression - rather than an identifier. + true if set has an + attribute named s, and + false otherwise. This is a dynamic version of + the ? operator, since + s is an expression rather than an + identifier. @@ -331,12 +331,12 @@ stdenv.mkDerivation { Load, parse and return the Nix expression in the file path. If path is a directory, the file default.nix - in that directory is loaded. Evaluation aborts if - the file doesn’t exist or contains an incorrect Nix - expression. import implements Nix’s module - system: you can put any Nix expression (such as an attribute set - or a function) in a separate file, and use it from Nix expressions - in other files. + in that directory is loaded. Evaluation aborts if the + file doesn’t exist or contains an incorrect Nix expression. + import implements Nix’s module system: you + can put any Nix expression (such as a set or a function) in a + separate file, and use it from Nix expressions in other + files. A Nix expression loaded by import must not contain any free variables (identifiers @@ -383,9 +383,9 @@ x: x + 456 builtins.intersectAttrs e1 e2 - Return an attribute set consisting of the - attributes in the set e2 that also - exist in the set e1. + Return a set consisting of the attributes in the + set e2 that also exist in the set + e1. @@ -394,7 +394,7 @@ x: x + 456 e Return true if - e evaluates to an attribute set, and + e evaluates to a set, and false otherwise. @@ -490,9 +490,9 @@ x: x + 456 builtins.listToAttrs e - Construct an attribute set from a list specifying - the names and values of each attribute. Each element of the list - should be an attribute set consisting of a string-valued attribute + Construct a set from a list specifying the names + and values of each attribute. Each element of the list should be + a set consisting of a string-valued attribute name specifying the name of the attribute, and an attribute value specifying its value. Example: @@ -547,7 +547,7 @@ 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 a set { name, version }. Thus, builtins.parseDrvName "nix-0.12pre12876" returns { name = "nix"; version = "0.12pre12876"; }. @@ -598,12 +598,12 @@ in config.someSetting removeAttrs - attrs list + set list Remove the attributes listed in - list from the attribute set - attrs. The attributes don’t have to - exist in attrs. For instance, + list from + set. The attributes don’t have to + exist in set. For instance, removeAttrs { x = 1; y = 2; z = 3; } [ "a" "x" "z" ] @@ -792,7 +792,7 @@ in foo servlet container. A servlet container contains a number of servlets (*.war files) each exported under a specific URI prefix. So the servlet configuration is a list of - attribute sets containing the path and + sets containing the path and war of the servlet (). This kind of information is difficult to communicate with the normal method of passing diff --git a/doc/manual/nix-env.xml b/doc/manual/nix-env.xml index 03111515a419..5f87093ac163 100644 --- a/doc/manual/nix-env.xml +++ b/doc/manual/nix-env.xml @@ -153,11 +153,10 @@ also . default. The Nix expressions in this directory are combined into a - single attribute set, with each file as an attribute that has the - name of the file. Thus, if ~/.nix-defexpr - contains two files, foo and - bar, then the default Nix expression will - essentially be + single set, with each file as an attribute that has the name of + the file. Thus, if ~/.nix-defexpr contains + two files, foo and bar, + then the default Nix expression will essentially be { @@ -405,7 +404,7 @@ $ nix-env -f ./foo.nix -i -E \ I.e., this evaluates to (f: (f {system = "i686-linux";}).subversionWithJava) (import ./foo.nix), thus selecting the subversionWithJava attribute from the -attribute set returned by calling the function defined in +set returned by calling the function defined in ./foo.nix. A dry-run tells you which paths will be downloaded or built from diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index 5ba3df56c7c9..4154926268e0 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -118,10 +118,10 @@ the single Nix expression in that directory stdenv.mkDerivation. mkDerivation is a function provided by stdenv that builds a package from a set of - 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 = + attributes. A set is just a list of + key/value pairs where each key is a string and each value is an + arbitrary Nix expression. They take the general form { + name1 = expr1; ... nameN = exprN; }. @@ -384,9 +384,9 @@ some fragments of This is where the actual composition takes place. Here we call the function imported from - ../applications/misc/hello/ex-1 with an - attribute set containing the things that the function expects, - namely fetchurl, stdenv, and + ../applications/misc/hello/ex-1 with a set + containing the things that the function expects, namely + fetchurl, stdenv, and perl. We use inherit again to use the attributes defined in the surrounding scope (we could also have written fetchurl = fetchurl;, etc.). @@ -805,20 +805,21 @@ to be enclosed in parentheses. If they had been omitted, e.g., [ 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. +function and the fifth being a set. -Attribute sets +Sets -Attribute sets are really the core of the language, since -ultimately it's all about creating derivations, which are really just +Sets are really the core of the language, since ultimately the +Nix language is all about creating derivations, which are really just sets of attributes to be passed to build scripts. -Attribute sets are just a list of name/value pairs enclosed in -curly brackets, where each value is an arbitrary expression terminated -by a semicolon. For example: +Sets are just a list of name/value pairs (called +attributes) enclosed in curly brackets, where +each value is an arbitrary expression terminated by a semicolon. For +example: { x = 123; @@ -826,12 +827,12 @@ by a semicolon. For example: y = f { bla = 456; }; } -This defines an attribute set with attributes named -x, text, y. -The order of the attributes is irrelevant. An attribute name may only -occur once. +This defines a set with attributes named x, +text, y. The order of the +attributes is irrelevant. An attribute name may only occur +once. -Attributes can be selected from an attribute set using the +Attributes can be selected from a set using the . operator. For instance, @@ -864,10 +865,10 @@ This will evaluate to 123.
Language constructs -Recursive attribute sets +Recursive sets -Recursive attribute sets are just normal attribute sets, but the -attributes can refer to each other. For example, +Recursive sets are just normal sets, but the attributes can +refer to each other. For example, rec { @@ -880,11 +881,11 @@ evaluates to 123. Note that without rec the binding x = y; would refer to the variable y in the surrounding scope, if one exists, and would be invalid if no such variable exists. That -is, in a normal (non-recursive) attribute set, attributes are not -added to the lexical scope; in a recursive set, they are. +is, in a normal (non-recursive) set, attributes are not added to the +lexical scope; in a recursive set, they are. -Recursive attribute sets of course introduce the danger of -infinite recursion. For example, +Recursive sets of course introduce the danger of infinite +recursion. For example, rec { @@ -918,16 +919,16 @@ evaluates to "foobar". let { attrs }, which is translated to rec { attrs }.body. That is, the body of the let-expression is the -body attribute of the attribute set. +body attribute of the set. Inheriting attributes -When defining an attribute set it is often convenient to copy -variables from the surrounding lexical scope (e.g., when you want to -propagate attributes). This can be shortened using the +When defining a set it is often convenient to copy variables +from the surrounding lexical scope (e.g., when you want to propagate +attributes). This can be shortened using the inherit keyword. For instance, @@ -936,10 +937,10 @@ let x = 123; in 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 +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 set. For instance, in this fragment from all-packages.nix, @@ -958,13 +959,12 @@ from all-packages.nix, libjpg = ...; ... -the attribute set used in the function call to the function defined in +the set used in the function call to the function defined in ../tools/graphics/graphviz inherits a number of variables from the surrounding scope (fetchurl ... yacc), but also inherits libXaw (the X Athena Widgets) from the -xlibs (X11 client-side libraries) attribute -set. +xlibs (X11 client-side libraries) set. @@ -1003,11 +1003,11 @@ map (concat "foo") [ "bar" "bla" "abc" ] "fooabc" ]. - An attribute set pattern of the - 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 + 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 { x, y, z }: z + y + x @@ -1174,9 +1174,8 @@ used in the Nix expression for Subversion. with e1; e2 -introduces the attribute set e1 into the -lexical scope of the expression e2. For -instance, +introduces the set e1 into the lexical +scope of the expression e2. For instance, let as = { x = "foo"; y = "bar"; }; @@ -1235,7 +1234,7 @@ weakest binding). none Select attribute denoted by the attribute path - attrpath from attribute set + attrpath from set e. (An attribute path is a dot-separated list of attribute names.) If the attribute doesn’t exist, return def if @@ -1251,8 +1250,8 @@ weakest binding). e ? attrpath none - Test whether attribute set e - contains the attribute denoted by attrpath; + Test whether set e contains + the attribute denoted by attrpath; return true or false. @@ -1275,10 +1274,11 @@ weakest binding). e1 // e2 right - Return an attribute set consisting of the attributes in + Return a set consisting of the attributes in e1 and e2 (with the latter taking - precedence over the former in case of equally named attributes). + precedence over the former in case of equally named + attributes). e1 == @@ -1322,9 +1322,9 @@ weakest binding).
Derivations The most important built-in function is -derivation, which is used to describe a -single derivation (a build action). It takes as input an attribute -set, the attributes of which specify the inputs of the build. +derivation, which is used to describe a single +derivation (a build action). It takes as input a set, the attributes +of which specify the inputs of the build. -- cgit 1.4.1