[Nix-dev] Re: [Nix-commits] SVN commit: nix - 20581 - ludo - nixpkgs/trunk/pkgs/lib

Nicolas Pierron nicolas.b.pierron at gmail.com
Fri Mar 12 09:25:20 CET 2010


On Thu, Mar 11, 2010 at 23:03, Ludovic Courts <ludo at gnu.org> wrote:
> Author: ludo
> Date: 2010-03-11 22:03:49 +0000 (Thu, 11 Mar 2010)
> New Revision: 20581
>
> You can view the changes in this commit at:
>   https://svn.nixos.org/viewvc/nix?rev=20581&view=rev
>
> Modified:
>   nixpkgs/trunk/pkgs/lib/options.nix
>
> Log:
> options: Learn how to merge identical integer values.
>
> Changes:
>
> Modified: nixpkgs/trunk/pkgs/lib/options.nix
> ===================================================================
> --- nixpkgs/trunk/pkgs/lib/options.nix  2010-03-11 22:03:45 UTC (rev 20580)
> +++ nixpkgs/trunk/pkgs/lib/options.nix  2010-03-11 22:03:49 UTC (rev 20581)
> @@ -195,6 +195,8 @@
>     else if all isAttrs list then fold lib.mergeAttrs {} list
>     else if all builtins.isBool list then fold lib.or false list
>     else if all builtins.isString list then lib.concatStrings list
> +    else if all builtins.isInt list && all (x: x == head list) list
> +         then head list
>     else throw "Cannot merge values.";
>
>   mergeTypedOption = typeName: predicate: merge: list:

I disagree, this should not be a default behavior.  If you want
something like that you can create a new type which first check that
values are Integer and then merge them and fails with a cleaner error
message.

So I highly recommend that you revert this patch to replace it by a
type.  Types are not more difficult to write and they provide more
accruate information instead of "Cannot merge values".  In addition,
this behavior is not an usual case.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/



More information about the nix-dev mailing list