Skip to content

milahu/nix-eval-js

Repository files navigation

nix-eval-js

nix interpreter in javascript

status

early draft

for a list of implemented features, see test/nix-eval.snapshots.txt

autocompletion

a very simple version of autocompletion is working

this is based on the last valid eval state

see the demo

demo

nix-eval-js demo

documentation

see docs/

install

git clone --recurse-submodules https://github.com/milahu/nix-eval-js
cd nix-eval-js
pnpm install

commands

./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

offline demo

cd demo
pnpm install
npm run dev

goals

incremental evaluator

create a prototype for an incremental evaluator

example

__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

intellisense

autocompletion

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

Nix Interpreters

aka: Nix Evaluators

status = how much of "the perfect nix" is implemented

in a distant future, nickel can interpret nix tweag/nickel#93

see also nix-community/awesome-nix#133

related

keywords

  • nix evaluator in javascript
  • eval nix code in javascript
  • evaluate nix code in javascript