[Nix-dev] Re: ‘nix-instantiate --xml’ and self-referential attrsets

Ludovic Courtès ludo at gnu.org
Sun Apr 10 22:59:58 CEST 2011


Hi!

ludo at gnu.org (Ludovic Courtès) writes:

> --8<---------------cut here---------------start------------->8---
> let x = derivation {
>       name = "x"; builder = ./foo.sh; system = builtins.currentSystem;
>     };
>     y = { b = x; };
> in
>   x // y
> --8<---------------cut here---------------end--------------->8---
>
> Running ‘nix-instantiate --strict --eval-only --xml’ yields this:
>
> --8<---------------cut here---------------start------------->8---
> <?xml version='1.0' encoding='utf-8'?>
> <expr>
>   <derivation drvPath="/nix/store/b1pmg2fhxnlnxy0z9hfglgyk66wpa2ar-x.drv" outPath="/nix/store/fw6flnp42lqn9i62aknpch29sadds5pi-x">
>     <attr column="11" line="2" name="b" path="/home/ludo/src/nixpkgs/maintainers/scripts/gnu/self-ref.nix">
>       <derivation drvPath="/nix/store/b1pmg2fhxnlnxy0z9hfglgyk66wpa2ar-x.drv" outPath="/nix/store/fw6flnp42lqn9i62aknpch29sadds5pi-x">
>         <repeated />
>       </derivation>
>     </attr>
>
>     [...]
>
>   </derivation>
> </expr>
> --8<---------------cut here---------------end--------------->8---

Actually, isn’t this XML representation ambiguous?

It could just as well represent:

  let x = derivation {
            name = "x"; builder = ./foo.sh; system = builtins.currentSystem;
            b = x;
          };
  in x

though this one obviously leads to an infinite recursion.

In Nix derivations aren’t a disjoint type, but in the XML above they
/are/ disjoint.

Thanks,
Ludo’.




More information about the nix-dev mailing list