1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 15:11:35 +00:00
nixpkgs/lib/trivial.nix

41 lines
1,022 B
Nix
Raw Normal View History

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;
mergeAttrs = x: y: x // y;
2013-11-12 12:48:19 +00:00
# Take a function and evaluate it with its own returned value.
fix = f: let result = f result; in result;
# Flip the order of the arguments of a binary function.
flip = f: a: b: f b a;
2013-11-12 12:48:19 +00:00
# Pull in some builtins not included elsewhere.
inherit (builtins)
pathExists readFile isBool isFunction
2015-03-20 14:53:25 +00:00
isInt add sub lessThan
seq deepSeq;
2013-11-12 12:48:19 +00:00
# Return the Nixpkgs version number.
nixpkgsVersion =
let suffixFile = ../.version-suffix; in
readFile ../.version
+ (if pathExists suffixFile then readFile suffixFile else "pre-git");
# Whether we're being called by nix-shell.
inNixShell = builtins.getEnv "IN_NIX_SHELL" == "1";
# 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;
}