2009-02-09 09:51:03 -07:00
|
|
|
rec {
|
|
|
|
|
|
|
|
# Identity function.
|
|
|
|
id = x: x;
|
|
|
|
|
|
|
|
# Constant function.
|
|
|
|
const = x: y: x;
|
|
|
|
|
|
|
|
# Named versions corresponding to some builtin operators.
|
|
|
|
concat = x: y: x ++ y;
|
|
|
|
or = x: y: x || y;
|
|
|
|
and = x: y: x && y;
|
2009-07-02 02:58:30 -06:00
|
|
|
mergeAttrs = x: y: x // y;
|
2013-11-12 05:48:19 -07:00
|
|
|
|
2009-02-09 09:51:03 -07:00
|
|
|
# Take a function and evaluate it with its own returned value.
|
|
|
|
fix = f: let result = f result; in result;
|
|
|
|
|
2009-10-23 01:34:56 -06:00
|
|
|
# Flip the order of the arguments of a binary function.
|
|
|
|
flip = f: a: b: f b a;
|
|
|
|
|
2013-11-12 05:48:19 -07:00
|
|
|
# Pull in some builtins not included elsewhere.
|
|
|
|
inherit (builtins)
|
|
|
|
pathExists readFile isBool isFunction
|
2015-03-20 08:53:25 -06:00
|
|
|
isInt add sub lessThan
|
2015-07-23 09:41:35 -06:00
|
|
|
seq deepSeq genericClosure;
|
2013-11-12 05:48:19 -07:00
|
|
|
|
2014-02-19 10:47:48 -07:00
|
|
|
# Return the Nixpkgs version number.
|
|
|
|
nixpkgsVersion =
|
|
|
|
let suffixFile = ../.version-suffix; in
|
|
|
|
readFile ../.version
|
|
|
|
+ (if pathExists suffixFile then readFile suffixFile else "pre-git");
|
|
|
|
|
2015-02-16 03:57:36 -07:00
|
|
|
# Whether we're being called by nix-shell.
|
2014-02-19 11:00:51 -07:00
|
|
|
inNixShell = builtins.getEnv "IN_NIX_SHELL" == "1";
|
|
|
|
|
2015-02-16 03:57:36 -07:00
|
|
|
# Return minimum/maximum of two numbers.
|
|
|
|
min = x: y: if x < y then x else y;
|
|
|
|
max = x: y: if x > y then x else y;
|
|
|
|
|
2009-02-09 09:51:03 -07:00
|
|
|
}
|