Nix-eval-js: a nix interpreter in javascript

this is a toy project to explore intellisense for Nix

im using javascript for rapid prototyping,
maybe later porting to Rust / Nim / Cito / Dart / ReasonML / …

demo: nix-eval-js demo
source: GitHub - milahu/nix-eval-js: nix interpreter in javascript

see also Possible features and ideas · Issue #41 · nix-community/rnix-lsp · GitHub

imo the missing link in nix tooling is an incremental interpreter

my interpreter is based on the incremental lezer-parser (similar to tree-sitter)
so at least the parsing stage is incremental

to get an incremental interpreter, i need to add caching

challenge: fixpoint recursion

this could be part of a hybrid solution,
where nix repl evaluates nixpkgs to provide package arguments [1],
and nix-eval-js evaluates only one file to provide autocompletion

[1] https://github.com/milahu/nixos-config-webui/blob/03f4286ab76c3c946f0ae936299aec198d9df877/backend/src/repl.js

to discover attribute names in nixpkgs:

nix-repl> :l <nixpkgs>

nix-repl> builtins.toJSON (builtins.attrNames pkgs.nodejs.passthru)
"[\"interpreterName\",\"pkgs\",\"python\",\"updateScript\"]"

for repeated queries, nix repl is much faster than nix-instantiate
ideally nix would expose something like nrepl (a network-based repl)