···88 else { ${elemAt attrPath n} = atDepth (n + 1); };
89 in atDepth 0;
9091- /* Like `attrByPath', but without a default value. If it doesn't find the
92 path it will throw an error.
9394 Example:
···274 # The set to get the named attributes from
275 attrs: genAttrs names (name: attrs.${name});
276277- /* Collect each attribute named `attr' from a list of attribute
278 sets. Sets that don't contain the named attribute are ignored.
279280 Example:
···357 ) {} list_of_attrs;
358359360- /* Recursively collect sets that verify a given predicate named `pred'
361- from the set `attrs'. The recursion is stopped when the predicate is
362 verified.
363364 Example:
···439 listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
440441442- /* Like `mapAttrs', but allows the name of each attribute to be
443 changed in addition to the value. The applied function should
444- return both the new name and value as a `nameValuePair'.
445446 Example:
447 mapAttrs' (name: value: nameValuePair ("foo_" + name) ("bar-" + value))
···479 map (name: f name attrs.${name}) (attrNames attrs);
480481482- /* Like `mapAttrs', except that it recursively applies itself to
483 attribute sets. Also, the first argument of the argument
484 function is a *list* of the names of the containing attributes.
485···499 mapAttrsRecursiveCond (as: true) f set;
500501502- /* Like `mapAttrsRecursive', but it takes an additional predicate
503 function that tells it whether to recurse into an attribute
504- set. If it returns false, `mapAttrsRecursiveCond' does not
505 recurse, but does apply the map function. If it returns true, it
506 does recurse, and does not apply the map function.
507···655656 /* Merge sets of attributes and combine each attribute value in to a list.
657658- Like `lib.attrsets.zipAttrsWith' with `(name: values: values)' as the function.
659660 Example:
661 zipAttrs [{a = "x";} {a = "y"; b = "z";}]
···88 else { ${elemAt attrPath n} = atDepth (n + 1); };
89 in atDepth 0;
9091+ /* Like `attrByPath`, but without a default value. If it doesn't find the
92 path it will throw an error.
9394 Example:
···274 # The set to get the named attributes from
275 attrs: genAttrs names (name: attrs.${name});
276277+ /* Collect each attribute named `attr` from a list of attribute
278 sets. Sets that don't contain the named attribute are ignored.
279280 Example:
···357 ) {} list_of_attrs;
358359360+ /* Recursively collect sets that verify a given predicate named `pred`
361+ from the set `attrs`. The recursion is stopped when the predicate is
362 verified.
363364 Example:
···439 listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
440441442+ /* Like `mapAttrs`, but allows the name of each attribute to be
443 changed in addition to the value. The applied function should
444+ return both the new name and value as a `nameValuePair`.
445446 Example:
447 mapAttrs' (name: value: nameValuePair ("foo_" + name) ("bar-" + value))
···479 map (name: f name attrs.${name}) (attrNames attrs);
480481482+ /* Like `mapAttrs`, except that it recursively applies itself to
483 attribute sets. Also, the first argument of the argument
484 function is a *list* of the names of the containing attributes.
485···499 mapAttrsRecursiveCond (as: true) f set;
500501502+ /* Like `mapAttrsRecursive`, but it takes an additional predicate
503 function that tells it whether to recurse into an attribute
504+ set. If it returns false, `mapAttrsRecursiveCond` does not
505 recurse, but does apply the map function. If it returns true, it
506 does recurse, and does not apply the map function.
507···655656 /* Merge sets of attributes and combine each attribute value in to a list.
657658+ Like `lib.attrsets.zipAttrsWith` with `(name: values: values)` as the function.
659660 Example:
661 zipAttrs [{a = "x";} {a = "y"; b = "z";}]
+11-11
lib/customisation.nix
···3rec {
456- /* `overrideDerivation drv f' takes a derivation (i.e., the result
7- of a call to the builtin function `derivation') and returns a new
8 derivation in which the attributes of the original are overridden
9- according to the function `f'. The function `f' is called with
10 the original derivation attributes.
1112- `overrideDerivation' allows certain "ad-hoc" customisation
13 scenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance,
14 if you want to "patch" the derivation returned by a package
15 function in Nixpkgs to build another version than what the
···104 else result;
105106107- /* Call the package function in the file `fn' with the required
108 arguments automatically. The function is called with the
109- arguments `args', but any missing arguments are obtained from
110- `autoArgs'. This function is intended to be partially
111 parameterised, e.g.,
112113 callPackage = callPackageWith pkgs;
···116 libbar = callPackage ./bar.nix { };
117 };
118119- If the `libbar' function expects an argument named `libfoo', it is
120 automatically passed as an argument. Overrides or missing
121- arguments can be supplied in `args', e.g.
122123 libbar = callPackage ./bar.nix {
124 libfoo = null;
···255 in lib.deepSeq drv' drv';
256257 /* Make a set of packages with a common scope. All packages called
258- with the provided `callPackage' will be evaluated with the same
259 arguments. Any package in the set may depend on any other. The
260 `overrideScope'` function allows subsequent modification of the package
261 set in a consistent way, i.e. all packages in the set will be
262 called with the overridden packages. The package sets may be
263 hierarchical: the packages in the set are called with the scope
264- provided by `newScope' and the set provides a `newScope' attribute
265 which can form the parent scope for later package sets. */
266 makeScope = newScope: f:
267 let self = f self // {
···3rec {
456+ /* `overrideDerivation drv f` takes a derivation (i.e., the result
7+ of a call to the builtin function `derivation`) and returns a new
8 derivation in which the attributes of the original are overridden
9+ according to the function `f`. The function `f` is called with
10 the original derivation attributes.
1112+ `overrideDerivation` allows certain "ad-hoc" customisation
13 scenarios (e.g. in ~/.config/nixpkgs/config.nix). For instance,
14 if you want to "patch" the derivation returned by a package
15 function in Nixpkgs to build another version than what the
···104 else result;
105106107+ /* Call the package function in the file `fn` with the required
108 arguments automatically. The function is called with the
109+ arguments `args`, but any missing arguments are obtained from
110+ `autoArgs`. This function is intended to be partially
111 parameterised, e.g.,
112113 callPackage = callPackageWith pkgs;
···116 libbar = callPackage ./bar.nix { };
117 };
118119+ If the `libbar` function expects an argument named `libfoo`, it is
120 automatically passed as an argument. Overrides or missing
121+ arguments can be supplied in `args`, e.g.
122123 libbar = callPackage ./bar.nix {
124 libfoo = null;
···255 in lib.deepSeq drv' drv';
256257 /* Make a set of packages with a common scope. All packages called
258+ with the provided `callPackage` will be evaluated with the same
259 arguments. Any package in the set may depend on any other. The
260 `overrideScope'` function allows subsequent modification of the package
261 set in a consistent way, i.e. all packages in the set will be
262 called with the overridden packages. The package sets may be
263 hierarchical: the packages in the set are called with the scope
264+ provided by `newScope` and the set provides a `newScope` attribute
265 which can form the parent scope for later package sets. */
266 makeScope = newScope: f:
267 let self = f self // {
+1-1
lib/default.nix
···1/* Library of low-level helper functions for nix expressions.
2 *
3 * Please implement (mostly) exhaustive unit tests
4- * for new functions in `./tests.nix'.
5 */
6let
7
···1/* Library of low-level helper functions for nix expressions.
2 *
3 * Please implement (mostly) exhaustive unit tests
4+ * for new functions in `./tests.nix`.
5 */
6let
7
+3-3
lib/lists.nix
···242243 /* Return a singleton list or an empty list, depending on a boolean
244 value. Useful when building lists with optional elements
245- (e.g. `++ optional (system == "i686-linux") firefox').
246247 Type: optional :: bool -> a -> [a]
248···283 */
284 toList = x: if isList x then x else [x];
285286- /* Return a list of integers from `first' up to and including `last'.
287288 Type: range :: int -> int -> [int]
289···320 ) { right = []; wrong = []; });
321322 /* Splits the elements of a list into many lists, using the return value of a predicate.
323- Predicate should return a string which becomes keys of attrset `groupBy' returns.
324325 `groupBy'` allows to customise the combining function and initial value
326
···242243 /* Return a singleton list or an empty list, depending on a boolean
244 value. Useful when building lists with optional elements
245+ (e.g. `++ optional (system == "i686-linux") firefox`).
246247 Type: optional :: bool -> a -> [a]
248···283 */
284 toList = x: if isList x then x else [x];
285286+ /* Return a list of integers from `first` up to and including `last`.
287288 Type: range :: int -> int -> [int]
289···320 ) { right = []; wrong = []; });
321322 /* Splits the elements of a list into many lists, using the return value of a predicate.
323+ Predicate should return a string which becomes keys of attrset `groupBy` returns.
324325 `groupBy'` allows to customise the combining function and initial value
326
+1-1
lib/meta.nix
···27 setName = name: drv: drv // {inherit name;};
282930- /* Like `setName', but takes the previous name as an argument.
3132 Example:
33 updateName (oldName: oldName + "-experimental") somePkg
···27 setName = name: drv: drv // {inherit name;};
282930+ /* Like `setName`, but takes the previous name as an argument.
3132 Example:
33 updateName (oldName: oldName + "-experimental") somePkg