[Nix-dev] Derivation equality

Ludovic Courtès ludo at gnu.org
Fri Jan 20 23:37:19 CET 2012


Hello!

Eelco Dolstra <e.dolstra at tudelft.nl> skribis:

> Author: eelco
> Date: Thu Jan 19 23:08:47 2012
> New Revision: 31729
> URL: https://nixos.org/websvn/nix/?rev=31729&sc=1
>
> Log:
> * Allow comparisons between derivations by comparing the outPath
>   attributes.
>
> Modified:
>    nix/trunk/src/libexpr/eval.cc
>
> Modified: nix/trunk/src/libexpr/eval.cc
> ==============================================================================
> --- nix/trunk/src/libexpr/eval.cc	Thu Jan 19 23:07:42 2012	(r31728)
> +++ nix/trunk/src/libexpr/eval.cc	Thu Jan 19 23:08:47 2012	(r31729)
> @@ -1245,11 +1245,23 @@
>              return true;
>  
>          case tAttrs: {
> +            /* If both attribute sets denote a derivation (type =
> +               "derivation"), then compare their outPaths. */
> +            if (isDerivation(v1) && isDerivation(v2)) {
> +                Bindings::iterator i = v1.attrs->find(sOutPath);
> +                Bindings::iterator j = v2.attrs->find(sOutPath);
> +                if (i != v1.attrs->end() && j != v2.attrs->end())
> +                    return eqValues(*i->value, *j->value);
> +            }

Isn’t it risky to special-case derivations, given that derivations are
not a disjoint type?  One would expect the meaning of ‘==’ to be the
same for all attribute sets, including derivations.

Thanks,
Ludo’.


More information about the nix-dev mailing list