about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/impure.rs (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-10-16 r/5141 fix(tvix/eval): don't coerce variable name to stringsterni1-3/+3
Change-Id: I8aa878dee009901feb453c489ce37c12fa3a31a8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7026 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: Adam Joseph <adam@westernsemico.com> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-10 r/5097 fix(tvix/eval): Actually trace spans for thunksGriffin Smith1-1/+1
Currently, the span on *all* thunk force errors is the span at which the thunk is forced, which for recursive thunk forcing ends up just being the same span over and over again. This changes the span on thunk force errors to be the span at which point the thunk is *created*, which is a bit more helpful (though the printing atm is a little... crowded). To make this work, we have to thread through the span at which a thunk is created into a field on the thunk itself. Change-Id: I81474810a763046e2eb3a8f07acf7d8ec708824a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6932 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: Adam Joseph <adam@westernsemico.com> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-10 r/5096 feat(tvix/eval): Implement builtins.getEnvGriffin Smith1-1/+7
Change-Id: I09f512a60989a37184e73e521d4a3aa23f33a1a8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6922 Autosubmit: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: Adam Joseph <adam@westernsemico.com> Reviewed-by: kanepyork <rikingcoding@gmail.com>
2022-10-10 r/5095 feat(tvix/eval): Implement builtins.readFileGriffin Smith1-1/+7
Change-Id: If3fd0b087009a2bfbad8bb7aca0aa20de906eb12 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6921 Tested-by: BuildkiteCI Reviewed-by: Adam Joseph <adam@westernsemico.com> Reviewed-by: kanepyork <rikingcoding@gmail.com> Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: tazjin <tazjin@tvl.su>
2022-10-10 r/5088 feat(tvix/eval): Implement builtins.pathExistsGriffin Smith1-6/+7
Change-Id: Ife8a690e9036868964771893ab29a9ae3a2d2365 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6919 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-10 r/5083 feat(tvix/eval): Support builtins.readDirWilliam Carroll1-2/+39
Co-authored-by: Griffin Smith <root@gws.fyi> Change-Id: I5ff19efbe87d8f571f22ab0480500505afa624c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6552 Autosubmit: wpcarro <wpcarro@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-08 r/5068 feat(tvix/tests): Import default.nix inside directoryGriffin Smith1-1/+4
This requires actually passing the source directory into `interpret` in the eval tests, but otherwise this is fairly straightforward - if we're trying to import a directory, just push `default.nix` onto it and import that instead. Change-Id: I0b7d4234f81977e78d14dfa651bf0cf9721017e5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6893 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-10-08 r/5063 feat(tvix/eval): fancy-format parse errors returned by rnixVincent Ambo1-2/+3
This change is quite verbose, so a little bit of explaining: 1. To correctly format parse errors, errors must be able to return more than one annotated span (the parser returns a list of errors for each span). To accomplish this, the structure of how the `Diagnostic` struct which formats an error is constructed has changed to delegate the creation of the `SpanLabel` vector to the kind of error. 2. The rnix structures don't have human-readable output formats by default, so some verbose methods for formatting them in human-readable ways have been added in the errors module. We might want to move these out into a submodule. 3. In many cases, the errors returned by rnix are a bit strange - so while we format them with all information that is easily available they may look weird or not necessarily help users. Consider this CL only a first step in the right direction. Change-Id: Ie7dd74751af9e7ecb35d751f8b087aae5ae6e2e8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6871 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2022-10-07 r/5050 feat(tvix/eval): coerce values to paths when importingVincent Ambo1-12/+1
This enables the use of string paths (and, in the future, derivations), as long as their string values represent an absolute path. Change-Id: I4b198efeb70415ed52f58bd1da6fa79a24dad14c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6866 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-10-07 r/5049 feat(tvix/eval): add method for emitting runtime warningsVincent Ambo1-4/+4
This lets the VM emit warnings when it encounters situations that should only be warned about at runtime. For starters, this is used to pass through compilation warnings that come up when `import` is used. Change-Id: I0c4bc8c534d699999887c430d93629fadfa662c4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6868 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2022-10-07 r/5048 feat(tvix/eval): insert `import` into the builtins itselfVincent Ambo1-2/+6
Adding `import` to builtins causes causes a bootstrap cycle because the `import` builtin needs to be initialised with the set of globals before being inserted into the globals, which also must contain itself. To break out of the cycle this hack wraps the builtins passed to the compiler in an `Rc` (probably sensible anyways, as they will end up getting cloned a bunch), containing a RefCell which gives us mutable access to the builtins. This opens up a potentially dangerous footgun in which we could mutate the builtins at runtime leading to different compiler invocations seeing different builtins, so it'd be nice to have some kind of "finalised" status for them or some such, but I'm not sure how to represent that atm. Change-Id: I25f8d4d2a7e8472d401c8ba2f4bbf9d86ab2abcb Reviewed-on: https://cl.tvl.fyi/c/depot/+/6867 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-10-06 r/5041 feat(tvix/eval): initial implementation of `builtins.import`Vincent Ambo1-5/+79
This adds an initial working version of builtins.import which encapsulates the entire functionality of `import` within the builtin itself, without requiring any changes in the compiler or VM. The key insight that enables this is that we can simply return a Thunk from `import` that is constructed from the output of running the compiler and - ta-da! - no other component needs to know about it. A couple of notes: * builtins.import needs to capture variables like the SourceCode structure. This means it can not currently be constructed the same way as other builtins and has special handling, which leaks out to `eval.rs`. I have postponed dealing with that until we have this working a bit more. * the `globals` are not yet passed through * the error representation for the new variants is absolutely not done yet, we probably want to switch to something that supports cause-chaining now (like miette) * there is no mechanism for emitting warnings at runtime; we need to add that Change-Id: I3117a7ae3ff2432bf44f5ff05ad35f47faca31d5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6857 Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-10-04 r/5027 feat(tvix/eval): implement `builtins.currentTime`Vincent Ambo1-2/+12
Returns time since epoch in seconds. This has a slight behaviour difference from Nix, in that we don't pin the time between REPL entries (Nix pins it for the program lifetime), but this is probably inconsequential as long as it is pinned during an evaluation. Change-Id: I010c02e93097a209d8ad69e278397c7e30e54c86 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6846 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: wpcarro <wpcarro@gmail.com>
2022-10-04 r/5026 refactor(tvix/eval): allow impure Value builtinsVincent Ambo1-3/+22
Allows impure builtins that have a different shape than a Rust function pointer; specifically this is required for builtins.currentTime which does not work in WASM. Change-Id: I1362d8eeafe770ce4d1c5ebe4d119aeb0abb5c9b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6849 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: wpcarro <wpcarro@gmail.com>
2022-09-22 r/4954 feat(tvix/eval): Sketch out impure builtinsGriffin Smith1-0/+7
Sketch out a new set of "impure" builtins, which supplement the existing set of "pure" builtins but are gated behind a feature flag, which allows them to be omitted by crates depending on tvix-eval that only want pure evaluation, such as tvixbolt. Change-Id: I2736017b5c9b4776bbba8758e108ec84887abd66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6655 Reviewed-by: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su>