Does the nix expression language have a specification?

I am getting around to fully learning the nix expression language.
I’m curious if it has a specification or detailed implementation documentation.

Do you know of any?

If not, what sources have you used to understand the language in depth?

My hope would be to read a specification to determine whether parsing errors like decimal floats without leading zero causes a parsing failure · Issue #46 · nix-community/rnix-parser · GitHub are correct behavior.

3 Likes

According to this stackoverflow thread there is no formal specification, and currently the ultimate source is the lexer.

On the other hand, there are also the hnix and rnix projects that may have a spec (haven’t checked yet).

Apologies for the sloppy answer and the lack of links, and will update this when at the laptop again.

1 Like

I perused the source of hnix, rnix-parser, and nix itself.
I did not find any documentation about the language specification.

hnix actually embed’s a version of the lexer in their doc directory!
rnix-parser seems to be a Rust port of the parsing and lexing.

So I’m making the generalization that the Nix expression language is underspecified. I find it helpful knowing the tradeoffs.

As an aside, I don’t find this problematic. I’d guess that the more formalized nickel will supersede nix expression language someday.

2 Likes

Wanted to suggest an RFC for it but not sure if the reason for the lack of a formal Nix language specification is a deliberate choice or the lack of human-power to keep it maintained.

Totally missed this, thanks!

Thanks for the reminder regarding Nickel; there is also this thread you may be interested in:

(Along with the periodic Tweag + Nix dev updates.)

1 Like
Hosted by Flying Circus.