nix interpreter in javascript
early draft
for a list of implemented features, see test/nix-eval.snapshots.txt
a very simple version of autocompletion is working
this is based on the last valid eval state
see the demo
see docs/
git clone --recurse-submodules https://github.com/milahu/nix-eval-js
cd nix-eval-js
pnpm install
./bin/nix-parse -e 1+1
./bin/nix-eval -e 1+1
./bin/nix-parse -f /etc/nixos/configuration.nix
./bin/nix-eval -f /etc/nixos/configuration.nix
./bin/nix-parse -f ~/src/nixpkgs/pkgs/top-level/all-packages.nix
./bin/nix-eval -f ~/src/nixpkgs/pkgs/top-level/all-packages.nix
cd demo
pnpm install
npm run dev
create a prototype for an incremental evaluator
__head [ 1 ]
this evaluates to the result 1
adding values to the list does not change the result
__head [ 1 2 ]
still evaluates to the result 1
only changing the first value changes the result
__head [ 3 ]
this evaluates to the result 3
let
pkgs = {
hello = ''
#! /bin/sh
echo hello
'';
};
in
pkgs.
# ^ cursor
at this cursor, i want the autocompletion hello
this should also work with callPackage
and makeScope
aka: Nix Evaluators
status = how much of "the perfect nix" is implemented
- nix - the original nix interpreter in C++. aka
nix.cc
. Status: 90% - tour of nix - nix interpreter in javascript. aka
nix.js
.
the original nix interpreter, compiled to asm.js. Status:nix-instantiate
- https://nixcloud.io/tour/
- https://lastlog.de/blog/posts/tour_of_nix.html
- NixOS/nixpkgs#16208 - emscripten based toolchain for nix
- hnix - nix interpreter in haskell. aka
nix.hs
. Status: 50% - rnix-lsp - nix interpreter in rust. error-tolerant interpreter for intellisense. based on the rnix-parser. aka
nix.rs
. Status: 20% - Toros - Nix implementation in Rust. Based on the NixEL parser. aka
nix.rs
. Status: 10% - nix-eval-js - Nix interpreter in pure JavaScript. Proof of concept. Based on the lezer-parser-nix parser. aka
nix.js
. Status: 5%
in a distant future, nickel can interpret nix tweag/nickel#93
see also nix-community/awesome-nix#133
- lezer-parser-nix - nix parser in javascript
- nixos-config-webui - old project
- nijs - Nix bindings for JavaScript
- nix evaluator in javascript
- eval nix code in javascript
- evaluate nix code in javascript