[Nix-dev] builtins.toXML vs nix-instantiate --xml

Sergey Mironov grrwlf at gmail.com
Fri May 23 09:25:16 CEST 2014


Hi! nix-instantiate's manpage says that xml schema used by --xml flag
.. is the same as that used by the  toXML built-in. From the other
hand, simple test shows that format is different (see below). --xml
adds additional attributes 'column', 'line' and 'type'. Is it a design
bug? I'd like to compare such XMLs (I'm writing some auto-tests) and
thus I'd be happy if both ways produce identical XML output for the
same NIX expression.

Regards,
Sergey

--

1) builtins.toXML

$ printf "`nix-instantiate --eval  --strict -E 'builtins.toXML (rec {
x = "foo"; y = x; })'`"
"<?xml version='1.0' encoding='utf-8'?>
<expr>
  <attrs>
    <attr name="x">
      <string value="foo" />
    </attr>
    <attr name="y">
      <string value="foo" />
    </attr>
  </attrs>
</expr>
"

2) nix-instantiate --xml

$ nix-instantiate --eval --xml --strict -E 'rec { x = "foo"; y = x; }'
<?xml version='1.0' encoding='utf-8'?>
<expr>
  <attrs>
    <attr column="7" line="1" name="x" path="(string)">
      <string value="foo" />
    </attr>
    <attr column="18" line="1" name="y" path="(string)">
      <string value="foo" />
    </attr>
  </attrs>
</expr>


More information about the nix-dev mailing list