1rec {
2
3 # Identity function.
4 id = x: x;
5
6 # Constant function.
7 const = x: y: x;
8
9 # Named versions corresponding to some builtin operators.
10 concat = x: y: x ++ y;
11 or = x: y: x || y;
12 and = x: y: x && y;
13 mergeAttrs = x: y: x // y;
14
15 # Take a function and evaluate it with its own returned value.
16 fix = f: let result = f result; in result;
17
18 # Flip the order of the arguments of a binary function.
19 flip = f: a: b: f b a;
20
21 # Pull in some builtins not included elsewhere.
22 inherit (builtins)
23 pathExists readFile isBool isFunction
24 isInt add sub lessThan
25 seq deepSeq genericClosure;
26
27 # Return the Nixpkgs version number.
28 nixpkgsVersion =
29 let suffixFile = ../.version-suffix; in
30 readFile ../.version
31 + (if pathExists suffixFile then readFile suffixFile else "pre-git");
32
33 # Whether we're being called by nix-shell.
34 inNixShell = builtins.getEnv "IN_NIX_SHELL" == "1";
35
36 # Return minimum/maximum of two numbers.
37 min = x: y: if x < y then x else y;
38 max = x: y: if x > y then x else y;
39
40}