This document sketches out how devenv could be using Tvix, instead of Nix for Evaluation.
Currently building with Tvix as well is out of scope, but we're fine with Tvix ingesting things in its own (in-memory or semi-ephemeral in a cache directory) store, and copying from there into the "real" Nix store.
Ultimately, devenv evaluates a few attrpaths in a Nix file. As internally fetchTree is used, it being supported in Tvix is a requirement.
Assuming there is fetchTree support, we can evaluate these files with Tvix too. After/while the evaluation happens, we copy fetched sources and evaluated Derivations into the Nix-managed store. We cannot (exclusively) rely on being able to talk to a running nix daemon to talk to and insert into there (single-user installations, docker containers), and don't want to FFI or manually change things inside the sqlite DB, so at least the fallback case would need to "unpack sources" and write .drv files to a temporary directory, then nix-store --add it.
- evaluate with Tvix, but wrap/traitify KnownPaths in a way so that we can observe what gets inserted (might need to wait until upcoming and necessary TvixStoreIO refactor)
- copy all new store pahs for sources into local /nix/store
- copy all new Derivations into local /nix/store (as ATerm)
- pay attention to insertion order to not refer to nonexistent things
- return list of drv/outpaths for evaluated attrpaths.
- In case there's a change, devenv can nix-build the Derivation(s) directly, no need to eval.
Speak the nix daemon protocol if a local nix daemon is running. Avoids having to "unpack" store paths, can be streamed to the daemon directly.
Eagerly start fetching Fetches as they get inserted into KnownPaths iff they don't exist in the store, with some configurable concurrency. EvalIO into these store paths needs to either block for completion, or get "rerouted" to a fetch done in the meantime.
- no IFD
- Shelling out to nix-store --add is ok, as we only need to do it once per new store path, and especially sources don't change that often.
- for now we only do fetches for sources with known-upfront NAR Hash, like in the lockfile. We don't use it to update the lockfile itself, so don't need to do any fetch caching initially.