[Nix-dev] Re: [Nix-commits] SVN commit: nix - 15553 - eelco - nix/trunk/src/libexpr

Nicolas Pierron nicolas.b.pierron at gmail.com
Mon May 11 19:49:16 CEST 2009


Hi Eelco,

I just want to warn you that NixOS should not compile anymore because
it relies on:
- attribute set comparison.
- function comparison.

To fix this I think we need an operator to verify the "same source as"
relation which is used by NixOS which should behave as commented on
the following examples:

let
  a = { x = 1; };
  b = a;
  c = (import ./foo) {};
  d = (import ./foo) {};
  e = (import ./foo) { pkgs = ./nixpkgs; };
in (sameSourceAs a a) == true
&& (sameSourceAs b a) == (sameSourceAs a b)
&& (sameSourceAs c d) == true
&& (sameSourceAs c e) == false

This type of comparison is used in NixOS to avoid circular imports of
option sets.  It is hidden inside the "uniqFlatten" function which
call the "elem" function.

Even if I approve the modification made to fit the specification of
the language I regret that no function had been introduce to convert
the "bad" comparison into something more-less stable before the
release of this modification.

Thanks,

On Mon, May 11, 2009 at 17:50, Eelco Dolstra <e.dolstra at tudelft.nl> wrote:
> Author: eelco
> Date: 2009-05-11 15:50:14 +0000 (Mon, 11 May 2009)
> New Revision: 15553
>
> You can view the changes in this commit at:
>   https://svn.nixos.org/viewvc/nix?rev=15553&view=rev
>
> Modified:
>   nix/trunk/src/libexpr/eval.cc
>
> Log:
> * Disallow equality tests between attribute sets.  This was always
>  broken, but now the evaluator checks for it to prevent Nix
>  expressions from relying on undefined behaviour.  Equality tests are
>  implemented using a shallow pointer equality test between ATerms.
>  However, because attribute sets are lazy and contain position
>  information, this can give false positives.  For instance,
>  previously
>
>    let y = {x = 1;}; in y == y
>
>  evaluated to true, while the equivalent expression
>
>    {x = 1;} == {x = 1;}
>
>  evaluated to false.  So disallow these tests for now.  (Eventually
>  we may want to implement deep equality tests for attribute sets,
>  like lib.eqStrict.)
>
> * Idem: disallow comparisons between functions.
>
> * Implemented deep comparisons of lists.  This had the same problem as
>  attribute sets - the elements in the list weren't evaluated.  For
>  instance,
>
>    ["xy"] == [("x" + "y")]
>
>  evaluated to false.  Now it works properly.


-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list