summaryrefslogtreecommitdiffstats
path: root/lib/lists.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 04:46:36 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-28 22:45:55 +0100
commit40913958a2c61e49348d2038ae6f2a1d32c126fe (patch)
tree02929d83462f084b245bcc7ebb948fbafc9b4c50 /lib/lists.nix
parentcfab329437a24811104bc8daa2b83b80614f753c (diff)
Keep position information for option declarations and definitions
Also, when an option definition fails to type-check, print the file name of the module in which the offending definition occurs, e.g. error: user-thrown exception: The option value `boot.loader.grub.version' in `/etc/nixos/configuration.nix' is not a integer.
Diffstat (limited to 'lib/lists.nix')
-rw-r--r--lib/lists.nix5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/lists.nix b/lib/lists.nix
index eb7e6baf5ed8..d0b09539bf69 100644
--- a/lib/lists.nix
+++ b/lib/lists.nix
@@ -118,6 +118,11 @@ in rec {
all = pred: fold (x: y: if pred x then y else false) true;
+ # Count how many times function `pred' returns true for the elements
+ # of `list'.
+ count = pred: fold (x: c: if pred x then inc c else c) 0;
+
+
# Return a singleton list or an empty list, depending on a boolean
# value. Useful when building lists with optional elements
# (e.g. `++ optional (system == "i686-linux") flashplayer').