From daa6f9c7ef754ab57c2d2f213d2abce35a01586a Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Sun, 25 Jan 2009 00:31:38 +0000 Subject: [PATCH] Add a common merge function. (mergeOneOption) This merge function allow only one definition for an option. svn path=/nixpkgs/trunk/; revision=13841 --- pkgs/lib/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index 5be1bb2908d..a44fdfa5edd 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -500,6 +500,11 @@ rec { (x: if builtins ? isString then builtins.isString x else x + "") concatStrings; + mergeOneOption = name: list: + if list == [] then abort "This case should never happens." + else if tail list != [] then throw "Multiple definitions. Only one is allowed for this option." + else head list; + # Handle the traversal of option sets. All sets inside 'opts' are zipped # and options declaration and definition are separated. If no option are