about summary refs log tree commit diff
path: root/tvix/cli
AgeCommit message (Collapse)AuthorFilesLines
2023-02-01 r/5807 refactor(tvix/cli): use nixhash module for output hash calculationFlorian Klink2-73/+20
This covers all the weird corner cases. Change-Id: I85637e82e8929828064ab562dc8a1c8bf161fffa Reviewed-on: https://cl.tvl.fyi/c/depot/+/7991 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2023-02-01 r/5799 feat(tvix/cli): implement builtins.placeholderVincent Ambo1-0/+26
This doesn't require any other corresponding handling *yet*, as the actual replacements happen in the builder logic (which we delegate to cppnix at the moment). Change-Id: I034147c933f05ae427c7a8794647132d108d0ede Reviewed-on: https://cl.tvl.fyi/c/depot/+/7972 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-31 r/5791 refactor(tvix/nix-compat): absorb //tvix/derivationFlorian Klink3-6/+7
Put this in its src/derivation. Change-Id: Ic047ab1c2da555a833ee454e10ef60c77537b617 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7967 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
2023-01-31 r/5788 refactor(tvix): introduce nix-compat crateFlorian Klink1-1/+0
Move nixbase32 and store_path into this. This allows //tvix/cli to not pull in //tvix/store for now. Change-Id: Id3a32867205d95794bc0d33b21d4cb3d9bafd02a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7964 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2023-01-31 r/5787 refactor(tvix/cli/derivation): use `if let` to destructureFlorian Klink1-5/+5
We only do logic here if algo and hash_mode are Some(_) (and there's an `out` output). The fact we don't do anything in all in other cases is a bit hidden at the bottom. Use if let for the destructuring, and drop the other case. Change-Id: Icc0e38e62947d52d48ef610f754749737977fca9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7966 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2023-01-31 r/5786 refactor(tvix/cli): remove unneeded cloneFlorian Klink1-2/+2
Change-Id: I6f4cb24bdd636af8918a2ade44075af92161c97d Reviewed-on: https://cl.tvl.fyi/c/depot/+/7965 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2023-01-31 r/5783 refactor(tvix/cli): absorb construct_output_hashFlorian Klink2-93/+116
This helper function only was created because populate_output_configuration was hard to test before cl/7939. With that out of the way, we can pull it in. Change-Id: I64b36c0eb34343290a8d84a03b0d29392a821fc7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7961 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2023-01-31 r/5782 refactor(tvix/cli): force outside of output configuration helperVincent Ambo1-54/+36
Change-Id: I28357fe131cefedcef9761b08a72f675f4a10789 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7939 Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2023-01-29 r/5776 refactor(tvix/cli): add helper method for strong string coercionVincent Ambo1-29/+29
This is repetitive and error prone (e.g. switching around to_string/as_str has drastic consequences) due to the ToString overloads. Change-Id: I9b16a2e0e05e4c21e83f43e9f603746eb42e53f7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7947 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su>
2023-01-27 r/5773 refactor(tvix/cli): describe errors with thiserrorFlorian Klink2-64/+16
This is much less code, and makes it much easier to read. Change-Id: I9028f226105f905c2cc2cabd33907ff493e26225 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7938 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
2023-01-27 r/5772 fix(tvix/cli): handle SRI hashes in outputHashFlorian Klink3-18/+146
Instead of being called with `md5`, `sha1`, `sha256` or `sha512`, `fetchurl.nix` (from corepkgs / `<nix`) can also be called with a `hash` attribute, being an SRI hash. In that case, `builtin.derivation` is called with `outputHashAlgo` being an empty string, and `outputHash` being an SRI hash string. In other cases, an SRI hash is passed as outputHash, but outputHashAlgo is set too. Nix does modify these values in (single, fixed) output specification it serializes to ATerm, but keeps it unharmed in `env`. Move this into a construct_output_hash helper function, that can be tested better in isolation. Change-Id: Id9d716a119664c44ea7747540399966752e20187 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7933 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-27 r/5770 feat(tvix/cli): faux implementation of builtins.toFileVincent Ambo1-0/+31
This adds an implementation of this builtin which correctly calculates paths, but does not actually write anything to the store or verify references. Change-Id: Ie9764cbc1d13a73d8dc9350910304e2b7cad3fe8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7910 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-27 r/5769 feat(tvix/cli): implement `builtins.derivation`Vincent Ambo3-0/+41
This uses the actual upstream Nix code for `builtins.derivation` (which is not a primop in C++ Nix) to implement `builtins.derivation` as a wrapper around `builtins.derivationStrict`. We're doing it this way to ensure that our thunking logic is correct. An initial Rust-native rewrite (see e.g. cl/7363) is pretty difficult to debug while there are still other issues to root out, but eventually we might want to turn this into native code. Change-Id: I5845e18073e103b8670e40648bd7fd9b511058e0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7902 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-27 r/5768 feat(tvix/cli): implement builtins.derivationStrictVincent Ambo2-4/+154
Implements the logic for converting an evaluator value supplied as arguments to builtins.derivationStrict into an actual, fully-functional derivation struct. This skips the implementation of structuredAttrs, which are left for a subsequent commit. Note: We will need to port some eval tests over to CLI to test this correct, which will be done in a separate commit later on. Change-Id: I0db69dcf12716180de0eb0b126e3da4683712966 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7756 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-27 r/5767 feat(tvix/cli): add helper for handling special drv parametersVincent Ambo1-0/+106
Adds a helper function which handles special parameters to `builtins.derivation` that are not just blindly passed through to the builder environment, but populate other specific fields of the derivation (outside of the ones handled by other, more complex helpers from previous commits). Change-Id: I82d1edf9af714fc4591e9071c0b83ece83be7eee Reviewed-on: https://cl.tvl.fyi/c/depot/+/7901 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-27 r/5766 feat(tvix/cli): add helper for populating drv output configurationVincent Ambo2-2/+125
This threads through the fields that control whether a derivation is a fixed-output derivation or not. Change-Id: I49739de178fed9f258291174ca1a2c15a7cf5c2a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7900 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-27 r/5765 feat(tvix/cli): add helper for populating derivation inputsVincent Ambo1-0/+89
This adds a helper function which takes the output of the reference scanner used on derivation inputs and populates the `input_sources` and `input_derivations` field of the derivation accordingly. Note that we have a divergence from C++ Nix here, as we do not populate the entire FS closure of a literally referred derivation (and our standing theory is that this is unnecessary for nixpkgs). Change-Id: Id0f605dd8c0a82973c56605c2b8f478fc17777d6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7899 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-27 r/5764 feat(tvix/cli): add helper for populating derivation outputsVincent Ambo2-0/+89
Adds a small helper function which uses a Nix value supplied to `builtins.derivation{Strict}` to populate the `outputs` field of the `Derivation` struct. Change-Id: Iccc7a4f293b3d913140aed576a573a8992241e46 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7898 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-26 r/5760 fix(tvix/cli): correctly trim cppnix output in NixCompatIOVincent Ambo1-3/+4
We only stripped one of the two uses of this string, leading to extraneous newlines in the refscanner. Change-Id: I25d9119be082c487352f0cf66b97ecdcc3e1de06 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7932 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-20 r/5709 feat(tvix/cli): add `errors` module with drv construction errorsVincent Ambo3-0/+51
These will be threaded through to eval through the new `TvixError` variant. Change-Id: Ia0d3f8710dcf26bb95015cd2a6a2b2911f06343f Reviewed-on: https://cl.tvl.fyi/c/depot/+/7842 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-17 r/5677 refactor(tvix/cli): consistently assert type unity in known_pathsVincent Ambo1-46/+41
No situation should be allowed in which a path is inserted into known_paths with different types twice, which we previously enforced only for some path types. Change-Id: I8cb47d4b29c0aab3c58694f8b590e131deba7043 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7843 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-17 r/5673 feat(tvix/cli): add replacement strings tracking to KnownPathsVincent Ambo1-0/+29
Replacement strings are some weird internal feature of Nix that is required for calculating derivation hashes. We need to track these like other paths, as they need to be re-used on builds with dependencies on values from previous builds. Change-Id: Ie955b3fb5ae3685cfadfbe4d06ea6b5e219590c7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7828 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-17 r/5672 feat(tvix/cli): track known plain paths in NixCompatIOVincent Ambo3-27/+45
When adding things to a C++ Nix store, ensure that the path is tracked in the tracker. Since the mechanism for propagating the tracker instance isn't finalised yet, I've opted to take an Rc<RefCell> parameter for it. How exactly that ends up there is going to become clear in the next commits, but for now it's just instantiated in main with Default::default. Change-Id: I90f0b44f2d4f292dedc98ff1aa39041d279b61fd Reviewed-on: https://cl.tvl.fyi/c/depot/+/7833 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-17 r/5671 refactor(tvix/cli): reference scanner owns all the stringsVincent Ambo2-50/+29
This gets very complex very quickly otherwise, as all the construction paths for a reference scanner and all the access patterns for the KnownPaths structure are not yet fully understood. Change-Id: Ibadf1f18b476695f3c286fc6896ae557760edf63 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7827 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-17 r/5669 feat(tvix/cli): add known_paths moduleVincent Ambo3-5/+143
This module implements types used to track the set of known paths in the context of an evaluation. These are used to determine the build references of a derivation. Change-Id: I81e15ae33632784e699128916485751613b231a3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7816 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-01-11 r/5644 feat(tvix/refscan): implement reference scanning over data streamsVincent Ambo1-0/+40
Using yet more machinery from the pretty comprehensive aho_corasick crate, this makes it possible to pass anything implementing `io::Read` to the `ReferenceScanner` to accumulate matches. Change-Id: I5b0e28eb44ea4df24010f40831e29f2cbb8c1f80 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7810 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-11 r/5643 feat(tvix/cli): implement initial refscan moduleVincent Ambo3-0/+99
This module implements a ReferenceScanner struct which uses the aho_corasick crate to scan string inputs for known, non-overlapping candidates (store paths, in our case). I experimented with several different APIs, and landed on this version with an initial accumulator in the scanner. The scanner is instantiated from the candidates and "fed" all the strings, then consumed by the caller to retrieve the result. Right now only things that look vaguely like bytestrings can be fed to the scanner, there is no streaming support in the API yet. Change-Id: I7782f0f0df5fc64bccd813aa14712f5525b0168c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7808 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-06 r/5600 feat(tvix/cli): add `--compile-only` "linter" functionalityVincent Ambo1-1/+52
With this, tvix/cli can be run on files and only produce compiler errors and warnings. Change-Id: I5dd9229fc065647787daafd17d7c1540579a1d98 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7764 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-01-04 r/5581 refactor(tvix/eval): streamline construction of globals/builtinsVincent Ambo1-1/+1
Previously the construction of globals (a compiler-only concept) and builtins (a (now) user-facing API) was intermingled between multiple different modules, and kind of difficult to understand. The complexity of this had grown in large part due to the implementation of `builtins.import`, which required the notorious "knot-tying" trick using Rc::new_cyclic (see cl/7097) for constructing the set of globals. As part of the new `Evaluation` API users should have the ability to bring their own builtins, and control explicitly whether or not impure builtins are available (regardless of whether they're compiled in or not). To streamline the construction and allow the new API features to work, this commit restructures things by making these changes: 1. The `tvix_eval::builtins` module is now only responsible for exporting sets of builtins. It no longer has any knowledge of whether or not certain sets (e.g. only pure, or pure+impure) are enabled, and it has no control over which builtins are globally available (this is now handled in the compiler). 2. The compiler module is now responsible for both constructing the final attribute set of builtins from the set of builtins supplied by a user, as well as for populating its globals (that is identifiers which are available at the top-level scope). 3. The `Evaluation` API now carries a `builtins` field which is populated with the pure builtins by default, and can be extended by users. 4. The `import` feature has been moved into the compiler, as a special case. In general, builtins no longer have the ability to reference the "fix point" of the globals set. This should not change any functionality, and in fact preserves minor differences between Tvix/Nix that we already had (such as `builtins.builtins` not existing). Change-Id: Icdf5dd50eb81eb9260d89269d6e08b1e67811a2c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7738 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2022-12-22 r/5476 feat(tvix/cli): add `:d` REPL-prefix to print explanations of valuesVincent Ambo1-5/+14
Change-Id: I1dd8de8d996e07840f9b0aaebf932b812103a43a Reviewed-on: https://cl.tvl.fyi/c/depot/+/7593 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-12-22 r/5474 feat(tvix/cli): implement `NixCompatIO` helper typeVincent Ambo3-1/+86
This type allows for temporarily compatibility with the C++ Nix store, specifically (for now) it gives us the store directory used by Nix and imports files the same way. Change-Id: I4767794ef2863eba49661315c63c4e17de946d60 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7587 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-12-21 r/5461 fix(tvix/cli): use tvix_eval::StdIO in CLIVincent Ambo1-0/+1
... until we have a store-I/O layer, or something that intercepts the store-related stuff appropriately. Change-Id: I22f63435b3f9e118e3faeb2924fda8373a23ea7f Reviewed-on: https://cl.tvl.fyi/c/depot/+/7568 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-12-21 r/5456 chore(tvix/cli): rename binary to just 'tvix'Vincent Ambo1-0/+4
Change-Id: If735c81a04f60dcd77f1c40b595b52ed88bbbe95 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7580 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: flokli <flokli@flokli.de>
2022-12-21 r/5449 chore(tvix/cli): re-add observer flagsVincent Ambo1-2/+34
Users can again pass flags for dumping the AST, bytecode, and runtime trace. With this commit the CLI is at feature-parity with what we had before, but entirely through the new API. Change-Id: I30fe26f243224b25d1e4f828fec607325ef88306 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7550 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-12-21 r/5448 chore(tvix/cli): re-add NIX_PATH handlingVincent Ambo1-1/+7
Change-Id: I5595d6f5141ed4a533ca44a46264dc604fca6be1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7549 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
2022-12-21 r/5447 chore(tvix/cli): re-add `--raw` argumentVincent Ambo1-14/+15
Change-Id: I82f469f7f186c754c40bd941587b30aa3fc48045 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7548 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-12-21 r/5445 refactor(tvix/eval): consume `self` in Evaluation::evaluateVincent Ambo1-2/+2
This simplifies lifetime management for observers in callers of tvix_eval. Change-Id: I2f47c8d89f22b1c766526e5d1483c0d026b500ae Reviewed-on: https://cl.tvl.fyi/c/depot/+/7546 Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-12-21 r/5441 chore(tvix): upgrade to clap 4.0Vincent Ambo1-1/+1
In //tvix/eval: * criterion bumped to 4.0, which at least depends on clap 3.x instead of 2.x, which is less incompatible In //tvix/cli: * no changes required In //tvix/nix_cli: * some minor changes for compatibility with clap 4.0, no functionality changes Change-Id: If793f64b59fcaa2402d3d483ddbab4092f32df03 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7588 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
2022-12-21 r/5440 refactor(tvix): split binary (REPL etc.) out from evaluator libraryVincent Ambo3-0/+138
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