How does jsonnet compare with nix?

I mean for the instantiation phase - not for generating derivations or building anything.

/cc @edolstra re: Nix language changes · GitHub


How they see it:

The Nix expression language, which is a pure lazy functional language with dynamic typing, is therefore closer to Jsonnet. Jsonnet differs from the Nix expression language mainly in that it also has object-oriented semantics in the form of mixins. Also, Jsonnet is an extension of JSON, whereas the Nix expression language is not (in particular it lacks floating point numbers). Finally, the Nix expression language is an embedded part of the Nix package manager (and other tools), whereas Jsonnet is a standalone evaluator that can sit in front of anything that accepts JSON.

3 Likes

Sounds very similar to dhall. Assuming jsonnet’s intent is to have deterministic evaluation

At a previous job we had our test case data written in an ad-hoc developed format. I prototyped how it could look in Nix, jsonnet and Python and my conclusion was that, for declaring configuration, there was really not much difference between Nix and jsonnet. In the end we kept what we had because we were moving to something new altogether.

I recall that the overriding (with +:) was not sufficiently powerful enough, but I can’t remember the details. The standard library also felt very lacking and ad hoc. Other than that, I think there is value in it, though nothing Nix cannot do as well. Thus, I think it could be interesting if the Nix language / evaluator could be easily distributed/installed for just that purpose.

4 Likes
3 Likes