Open AmineChikhaoui opened 6 years ago
Btw --xml seems to work fine:
[amine@nixos:~/src/nix]$ nix-instantiate -E '(builtins.fetchGit https://github.com/NixOS/hydra)' --xml --eval-only --strict
<?xml version='1.0' encoding='utf-8'?>
<expr>
<attrs>
<attr name="outPath">
<string value="/nix/store/gmypid1qvrxpvqfh3dynhw8jap3j60cn-source" />
</attr>
<attr name="rev">
<string value="b542b73ced7a1ef6bc8f83e2918672068ccbc52c" />
</attr>
<attr name="revCount">
<int value="2544" />
</attr>
<attr name="shortRev">
<string value="b542b73" />
</attr>
</attrs>
</expr>
The issue here is that --json
uses the same code as builtins.toJSON
, which renders derivations as strings to prevent infinite recursion. (Regular derivations are circular data structures because the <output>
attributes refer back to themselves.)
@edolstra Hm ok, so I guess it would be a bit hard to fix. I was planning to use the json output to parse it from perl in hydra :/
@edolstra isn't it using type = "derivation"
to decide that? Or simply looking for an outPath
key?
Ah I guess it just looks for outPath
, so:
nix-repl> builtins.toJSON { outPath = "blah"; x = 5; }
"\"blah\""
@AmineChikhaoui This is an old issue, but this can be fixed by reassigning outPath
to something like _outPath
as I've done in my own projects. Since _outPath
will still be pointing to a valid derivation, it will output as the path (as you're seeing here), but the root derivation will be printed to JSON properly.
I marked this as stale due to inactivity. → More info