about summary refs log tree commit diff
path: root/tvix/eval/src/main.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-12-21 r/5440 refactor(tvix): split binary (REPL etc.) out from evaluator libraryVincent Ambo1-106/+0
The tvix-eval project is independent from any *uses* of the evaluator, such as the tvix-repl. This functionality has been split out into a separate "tvix-cli" crate. Note that this doesn't have to mean that this CLI crate is the "final" CLI crate for tvix, the point of this is not "getting the CLI structure right" but rather "getting the evaluator structure right". This reshuffling is part of restructuring the way that functionality like store communication is injected into language evaluation. Note that at this commit the new CLI crate is not at feature-parity. Change-Id: Id0af03dc8e07ef09a9f882a89612ad555eca8f93 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7541 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-11-26 r/5341 feat(tvix/eval): add --raw flag to eval, like cppnixAdam Joseph1-2/+13
Signed-off-by: Adam Joseph <adam@westernsemico.com> Change-Id: If07250a45fdf65a3f22ed8c37d7f37b45edccde9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7416 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-10-11 r/5103 feat(tvix/eval): Allow directly evaluating an expr via mainGriffin Smith1-0/+7
This *maybe* should do something to check that we don't pass both a file and an expr, but for now this is useful enough to cut corners (plus we're probably due for a CLI revamp eventually anyway). Change-Id: Id44357074150b336b6215ba596cc52d01d037dbd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6941 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-10 r/5087 feat(tvix/eval): Initial resolution of `<...>` pathsGriffin Smith1-1/+1
This commit implements (lazy) resolution of `<...>` paths via either the NIX_PATH environment variable, or the -I command-line flag - both handled via EvalOptions. As a result, EvalOptions can no longer derive Copy, meaning we have to clone it at each line of the repl - this is probably not a huge deal as repl performance is not exactly an inner loop and we're not cloning very much. Internally, this works by creating a thunk which pushes a constant containing the string inside the brackets to the stack, then a new opcode to resolve that path via the `NixPath`. To get that opcode to work, we now have to pass in the NixPath when constructing the VM. This (intentionally) leaves out proper implementation of path resolution via `findFile` (cppnix just calls whatever identifier called findFile is in scope!!!) as that's widely considered a bit of a misfeature, but if we do decide to implement that down the road it likely wouldn't be more than a few extra ops within the thunk introduced here. Change-Id: Ibc979b7e425b65cbe88599940520239a4a10cee2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6918 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-08 r/5070 feat(tvix/eval): Handle invoking binary with a directoryGriffin Smith1-9/+7
Similar to what we do for import, push on a `default.nix` to the path that the top-level is invoked with (if any) if it's a directory. Change-Id: I281bd44e3c8803b6765c886ae5fd08f549e2e563 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6895 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-10-04 r/5032 feat(tvix/eval): use fancy error formatting in REPLVincent Ambo1-1/+1
Change-Id: I8d5652d797b012bc3d5248ca2b2d0c87572dbf2e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6851 Tested-by: BuildkiteCI Reviewed-by: wpcarro <wpcarro@gmail.com>
2022-09-18 r/4911 refactor(tvix/eval): use Clap for arg+env parsingGriffin Smith1-14/+19
Refactor the environment variable and argument parsing for the tvix repl to use Clap instead of doing things ad-hoc, and thread through options obtained from environment variables via explicit arguments rather than obtaining them from the environment as they're needed. This makes adding more flags more sustainable, and also makes the binary fully self-documenting, including supported env vars, via `--help`. Change-Id: Ib1f6a0cd20056e8c9196760ff755fa5729667760 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6653 Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2022-09-10 r/4788 fix(tvix/eval): always add history entries in REPLVincent Ambo1-1/+1
... even if the code is broken. Change-Id: I5898bceaebf201b97e8988c94c90e7fafff82529 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6462 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-09-03 r/4617 refactor(tvix/eval): explicitly discard uninteresting resultsVincent Ambo1-2/+2
Change-Id: I95a2ad61d9512b91017c801f325d0193b4da9c7d Reviewed-on: https://cl.tvl.fyi/c/depot/+/6280 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-31 r/4547 fix(tvix/eval): gently attempt to create state dirVincent Ambo1-1/+3
If the directory in which REPL history is stored does not exist, gently try to create it, but do not raise an error if it doesn't work. We may want to warn about it, but in general this sort of non-essential feature should not cause a hard failure. Change-Id: If4fe8db0c7893c39627efe72c9cd9ebf7ed63f04 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6213 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-30 r/4537 fix(tvix/eval): address various clippy lintsVincent Ambo1-1/+3
Change-Id: I3ea0f51475e80948adfeb5d1620c1f2665cc39bc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6201 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-28 r/4519 feat(tvix/eval): resolve relative path literalsVincent Ambo1-3/+8
Resolves relative paths (e.g. `./foo`) either relative to the location of the Nix file, or relative to the working directory if none is supplied. Change-Id: I70ec574657b221b458015117a004b6e4a9c25a30 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6185 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2022-08-26 r/4505 feat(tvix/eval): use rustyline crate for REPLVincent Ambo1-19/+49
This is a substantially nicer experience, immediately granting us history, proper exiting and so on. Change-Id: Iba4cb1713b9ac53d0799722bdbe2cd0e94a2f527 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6171 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-08-25 r/4488 feat(tvix/eval): Expose interpret + related types from libGriffin Smith1-12/+1
Add a new `lib.rs` to tvix/eval, which `pub use`s the `interpret` function, and all types mentioned in its return type, and then uses *this* instead of direct `mod` statements in the `main.rs` to implement the entrypoints to the interpreter. This is in preparation for calling these functions from integrated benchmarking infrastructure using Criterion, though other things (like integration tests) might want to do that as well. Change-Id: I7b585134a96b1c56a2ac64d2036b0e51d321bd27 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6155 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: grfn <grfn@gws.fyi>
2022-08-24 r/4461 feat(tvix/tests): check in Nix' language test suiteVincent Ambo1-2/+5
This adds scaffolding code for running the Nix language test suite. The majority of eval-okay-* tests should eventually be runnable as-is by Tvix, however the eval-fail-* tests might not as we intend to have more useful error messages than upstream Nix. Change-Id: I4f3227f0889c55e4274b804a3072850fb78dd1bd Reviewed-on: https://cl.tvl.fyi/c/depot/+/6126 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4408 chore(tvix/eval): wire things up for development flowVincent Ambo1-1/+1
This creates a REPL which outputs compiled bytecode, constants, and VM results for code snippets. Change-Id: If63f79a961456afd6a4cdf59b994107ff7ab8b47 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6072 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: tazjin <tazjin@tvl.su>
2022-08-12 r/4407 feat(tvix/eval): add initial stack-based VMVincent Ambo1-0/+1
This can't do anything other than compute a single literal, for now Change-Id: Ia28f9da51c906b590a198e77a4ca5d45a871106b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6071 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4406 feat(tvix/eval): add initial barebones compilerVincent Ambo1-0/+1
This compiler can only take care of very trivial literals so far. Change-Id: I9dfac75a801b7235f868061a979ae24159fe1425 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6070 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4405 feat(tvix/eval): add initial chunk representationVincent Ambo1-0/+1
Change-Id: I53202e93938bede421c8f1c98901e4c67544e257 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6069 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4404 feat(tvix/eval): add initial opcode representationVincent Ambo1-0/+1
Change-Id: Ibc7685a6b0b92e08f0b6c82cf7d9b04fbb593a4e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6068 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4403 feat(tvix/eval): add initial value representationVincent Ambo1-0/+1
Change-Id: I427a04e89994662df2750dffe21991bad48aab15 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6066 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4401 chore(tvix/eval): bootstrap some evaluator boilerplateVincent Ambo1-1/+47
Change-Id: I7770a20948d18a8506c2418dea21202aa21a6ddc Reviewed-on: https://cl.tvl.fyi/c/depot/+/6064 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-08-12 r/4398 feat(tvix/eval): check in generated project skeletonVincent Ambo1-0/+3
Change-Id: Iecc8283abb289de71f22076fd88892f6ded99cb3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6062 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>