From 40913958a2c61e49348d2038ae6f2a1d32c126fe Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 28 Oct 2013 04:46:36 +0100 Subject: 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. --- lib/lists.nix | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/lists.nix') diff --git a/lib/lists.nix b/lib/lists.nix index eb7e6baf5ed..d0b09539bf6 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'). -- cgit 1.4.1