[Nix-dev] nix-instantiate --parse-only --xml

junger at stackframe.com junger at stackframe.com
Thu Jun 5 16:13:27 CEST 2008


On Wed, Jun 04, 2008 at 03:21:08PM -0400, junger at stackframe.com wrote:
> 
> Using nix-instantiate with --xml works great
> except that boolean types like:
> 
> 	ttyBackgrounds = {
> 		enable = true;
> 	};
> 
> get translated into XML as:
> 	 <attr name="ttyBackgrounds">
> 	     <unevaluated />
> 	 </attr>
> 	 
> regardless of the actual value.  Is this the normal behavior or a bug?

Well, I fixed this using the following small change to
src/libexpr/expr-to-xml.cc (this is nix-0.12pre11869):

48a49
>     ATerm t1;
67,72c68,69
<     else if (e == eTrue)
<         doc.writeEmptyElement("bool", singletonAttrs("value",
"true"));
< 
<     else if (e == eFalse)
<         doc.writeEmptyElement("bool", singletonAttrs("value",
"false"));
< 
---
>     else if (matchVar(e,t1))
>         doc.writeEmptyElement("bool", singletonAttrs("value",
>         aterm2String(t1)));

I really don't know if this is appropriate or correct but it generates
the expected XML (<bool value="false"/> or <bool value="true"/>).

I am most worried that matchVar is too general but matchBool doesn't
appear to work as boolean types are apparently showing up as 'Var'?  I
don't know if this holds across all cases.

Can anyone tell me if this is the right fix or not?

thank you,

James Unger



More information about the nix-dev mailing list