Hi Nicolas,

Nicolas Pierron <[email protected]> writes:

> On Thu, Mar 11, 2010 at 23:03, Ludovic Courts <[email protected]> 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.

The impetus was to allow several definitions of
‘boot.loader.grub.version = 2’, for instance.  I thought a bit about it
and I couldn’t come up with any other meaningful way to merge integers;
that is:

  - If the same value is found several times, use it.

  - If different values are found, there’s no sensible thing to do by
    default, so just throw “Cannot merge values”.

What makes you think it’s not as good a default as concatenating
strings, for instance?

Now, I must confess I don’t know much about types, so I should probably
look into it anyway.

Thanks for taking the time to review.

Ludo’.
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev

Reply via email to