Hello!

Consider this example:

--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---

When parsing this with SAX, the ‘repeated’ element is seen before the
first occurrence of the derivation, which is a problem: the program that
parses it doesn’t have anything to repeat yet.

I believe this patch fixes it:

--- nix/src/libexpr/expr-to-xml.cc~	2010-05-31 12:59:38.000000000 +0200
+++ nix/src/libexpr/expr-to-xml.cc	2011-04-09 17:23:26.000000000 +0200
@@ -138,8 +138,8 @@ static void printTermAsXML(Expr e, XMLWr
             XMLOpenElement _(doc, "derivation", xmlAttrs);
 
             if (drvsSeen.find(e) == drvsSeen.end()) {
-                drvsSeen.insert(e);
                 showAttrs(attrs, doc, context, drvsSeen, location);
+                drvsSeen.insert(e);
             } else
                 doc.writeEmptyElement("repeated");
         }
OK to apply, along with a test?

(For the record, I just encountered this problem for the first time with
‘buildInternalPythonModule’ in the Python 2.7 expression.)

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

Reply via email to