tvl-depot/tvix/eval
sterni 7165ebc43b fix(tvix/eval): remove incorrect imports when coercing
The default behavior of string coercion in C++ Nix is to weakly coerce
and import to store if necessary. There is a flag to make it strongly
coerce (coerceMore) and a flag that controls whether path values have
the corresponding file/directory imported into the store before
returning the (store) path as a string (copyToStore). We need to
implement our equivalent to the copyToStore (import_paths) flag for the
benefit of weak coercions that don't import into the store (dirOf,
baseNameOf, readFile, ...) and strong coercions that don't import into
the store (toString).

This makes coerce_to_string as well as CoercionKind weirder and more
versatile, but prevents us from reimplementing parts of the coercion
logic constantly as can be seen in the case of baseNameOf.

Note that it is not possible to test this properly in //tvix/eval tests
due to the lack of an appropriate EvalIO implementation being available.
Tests should be added to //tvix/glue down the line.

Change-Id: I8fb8ab99c7fe08e311d2ba1c36960746bf22f566
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10361
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: Adam Joseph <adam@westernsemico.com>
2023-12-14 13:15:23 +00:00
..
benches fix(tvix/eval/benches): use black_box properly 2023-11-02 20:39:52 +00:00
builtin-macros refactor(tvix/eval): address clippy lints 2023-12-09 12:58:39 +00:00
docs docs(tvix/eval): optimization potential for inherit (from) exprs 2023-11-24 23:36:15 +00:00
proptest-regressions/value refactor(tvix/eval): flatten call stack of VM using generators 2023-03-13 20:30:59 +00:00
src fix(tvix/eval): remove incorrect imports when coercing 2023-12-14 13:15:23 +00:00
tests refactor(tvix/eval/tests): migrate to tempfile 2023-10-08 22:47:33 +00:00
.skip-subtree feat(tvix/tests): check in Nix' language test suite 2022-08-24 21:25:41 +00:00
build.rs feat(tvix/eval): implement builtins.currentSystem 2022-10-24 12:20:01 +00:00
Cargo.toml chore(tvix): bump criterion to 0.5 2023-12-11 03:59:30 +00:00
default.nix refactor(tvix): build Rust projects using crate2nix 2022-12-15 17:26:45 +00:00
README.md docs(tvix/eval): update test suite documentation 2023-06-15 19:28:16 +00:00

Tvix Evaluator

This project implements an interpreter for the Nix programming language. You can experiment with an online version of the evaluator: tvixbolt.

The interpreter aims to be compatible with nixpkgs, on the foundation of Nix 2.3.

Important note: The evaluator is not yet feature-complete, and while the core mechanisms (compiler, runtime, ...) have stabilised somewhat, a lot of components are still changing rapidly.

Please contact TVL with any questions you might have.

Building tvix-eval

Please check the README.md one level up for instructions on how to build this.

The evaluator itself can also be built with standard Rust tooling (i.e. cargo build).

If you would like to clone only the evaluator and build it directly with Rust tooling, you can do:

git clone https://code.tvl.fyi/depot.git:/tvix/eval.git tvix-eval

cd tvix-eval && cargo build

Tests

Tvix currently has three language test suites for tvix-eval:

  • nix_tests and tvix_tests are based on the same mechanism borrowed from the C++ Nix implementation. They consist of Nix files as well as expected output (if applicable). The test cases are split into four categories: eval-okay (evaluates successfully with the expected output), eval-fail (fails to evaluate, no expected output), parse-okay (expression parses successfully, no expected output) and parse-fail (expression fails to parse, no expected output). Tvix currently ignores the last two types of test cases, since it doesn't implement its own parser.

    Both test suites have a notyetpassing directory. All test cases in here test behavior that is not yet supported by Tvix. They are considered to be expected failures, so you can't forget to move them into the test suite proper when fixing the incompatibility.

    Additionally, separate targets in the depot pipeline, under //tvix/verify-lang-tests, check both test suites (including notyetpassing directories) against C++ Nix 2.3 and the default C++ Nix version in nixpkgs. This way we can prevent accidentally introducing test cases for behavior that C++ Nix doesn't exhibit.

    • nix_tests has the test cases from C++ Nix's language test suite and is sporadically updated by manually syncing the directories. The notyetpassing directory shows how far it is until we pass it completely.

    • tvix_tests contains test cases written by the Tvix contributors. Some more or less duplicate test cases contained in nix_tests, but many cover relevant behavior that isn't by nix_tests. Consequently, it'd be nice to eventually merge the two test suites into a jointly maintained, common Nix language test suite.

      It also has a notyetpassing directory for missing behavior that is discovered while working on Tvix and isn't covered by the nix_tests suite.

  • nix_oracle can evaluate Nix expressions in Tvix and compare the result against C++ Nix (2.3) directly. Eventually it should gain the ability to property test generated Nix expressions. An additional feature is that it can evaluate expressions without --strict, so thunking behavior can be verified more easily.

rnix-parser

Tvix is written in memory of jD91mZM2, the author of rnix-parser who sadly passed away.

Tvix makes heavy use of rnix-parser in its bytecode compiler. The parser is now maintained by Nix community members.