Dear Nix community, I’m excited to announce the first release of Nickel! You can read the announcement blog post for a quick recap of the current capabilities, and to learn about what’s in and what’s coming next.
For this release, we have focused on designing the core language more than anything else. While it is not intended to be used in production yet, we hope to collect feedback and experience to help steer the future of the language in the right direction.
Using Nickel for Nix is, for the moment, quite limited. However, now that the 0.1.0 milestone has passed, this is very much our main focus for the near future: find a robust and ergonomic way of using Nickel as an alternative to write shells, packages, and modules, without disturbing the Nix ecosystem. We’ve already been thinking about it on and off for quite some time, and it poses particular challenges, such as how to leverage the existing Nix ecosystem without being drawn into the same issues we were trying to improve on in the first place.
In the meantime, @garbas , @regnat and I have been fiddling on the side with a hacky direct way to write simple derivations in Nickel: you can find our current lab at nickel-lang.
Let me conclude by quoting the blog post itself:
We are seeking for feedbacks, ideas and opinions. Yours are invaluable: please use Nickel, break it, do cool things we haven’t even imagined, and most importantly, please let us know about it!
Note that nickel-nix is just an experimentation. It’s not fleshed out, we cut corners, and most importantly, this is not what the future of using Nickel for Nix will look like, hopefully. We just sidestepped a lot of fundamental questions to get something working now. The “robust and ergonomic way of using Nickel as an alternative [for Nix]” mentioned as the roadmap will most likely gives us something different, involving a tighter integration of the two systems and languages.
I haven’t, and at first sight the resemblance is troubling! I’m going to read more about it, but it does seem to have very similar goals, scope and motivations. Really interesting. Thanks for sharing!
Yes, We plan to do so at some point, although for now I think the language is not stable enough to seriously start such an enterprise (in particular the merge system part). But we are currently writing down a formal specification of the type system, for example.
Having a specification was a point mentioned in the very first design document, exactly to make it not too hard to have an alternative implementation for the core language. The idea is that you could get light interpreters that just don’t care about types, and maybe contracts. But I suspect the latter may prove harder than initially thought, because contracts can already add default values, force fields to have some values, etc. which makes them conveniently schema-like but also means they impact the end result, and they are not all just checks that you can get rid of freely.
In any case, even without alternative implementations, a specification is important for solid foundations.
You can find information about docin the metadata section. This is used to attach documentation to any value. It can be leveraged by the nickel query command (or :q/:query in the REPL, for example try :q array and :q array.map), and later by a doc generator, when it will be available.
doc is to be followed by a string (a “static” string, it can’t be a compound expression, and it can’t have interpolation inside), and support markdown (as, the query command will render markdown natively, and the future doc generator as well).
Using several % in a multi string delimiter is used to write a string with literal %{ } or m%"/%"m inside without having to escape them. If you use n (say, 3) % in the opening delimiter like m%%%", then only the same number of % will be interpreted as interpolation ( %%%{exp}) or a closing delimiter "%%%m. For example:
{ foo | doc m%%"
Help interpolating zorglubs, as in `m%"%{foo zorglubs}"%m
"%%m }
$ nickel -f foo.ncl query foo
• documentation: Help interpolating zorglubs, as in m%"%{foo zorglubs}"%m