about summary refs log tree commit diff
path: root/tvix/nix-compat/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-11-05 r/6956 refactor(tvix/nix-compat): check presence with btree_map's entry APIVincent Ambo1-8/+9
Walking a btree_map twice is more expensive than copying a string, especially because the cloning only happens in the (non-hot) error path. This fixes a clippy lint, so it's related to b/321. Change-Id: I2ccfd0bc46792a45d277f47564e595b87107d8be Reviewed-on: https://cl.tvl.fyi/c/depot/+/9962 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-11-05 r/6955 chore(tvix): fix trivial clippy lintsVincent Ambo2-4/+4
Relates to b/321. Change-Id: I37284f89b186e469eb432e2bbedb37aa125a6ad4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9961 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su>
2023-11-05 r/6950 refactor(tvix/nix-compat): remove unused importsFlorian Klink1-2/+1
Change-Id: I64523df2344233d9e424812d94b1c7ed2ecb1a74 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9956 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-11-05 r/6949 refactor(tvix/nix-compat): use matches! macroFlorian Klink1-5/+1
Flagged by ``#[warn(clippy::match_like_matches_macro)]`.` Change-Id: If07109e5ec01b05df898119f9a577196dfe11b37 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9955 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-11-05 r/6948 refactor(tvix/nix-compat): drop useless try_into().expect()Florian Klink1-1/+1
This already has the right type. Change-Id: I8f5850a41f9e97f1bc5f2a45ca05cf7439665c9d Reviewed-on: https://cl.tvl.fyi/c/depot/+/9954 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2023-11-04 r/6940 fix(nix-compat/nixbase32): mark encode_len/decode_len constedef2-10/+3
Change-Id: Ib688bbb37cd54cfcd01e5cb3a8c376414ee8311e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9926 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-11-04 r/6939 refactor(tvix/glue): move builtins into separate directoryFlorian Klink1-0/+1
Change-Id: I25b7197458dbfbde8623545dc0a0286eb2744f10 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9911 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-10-28 r/6902 fix(nix-compat/narinfo): don't allocate errors earlyedef1-11/+12
We also switch the MissingField error to &'static str, since we only parse a fixed set of fields. Together, this makes the performance impact of error handling negligible in batch happy-path parsing. Change-Id: I2bd0ef2f5b35fcaced56b32d238eca75ac199ef1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9867 Reviewed-by: flokli <flokli@flokli.de> Autosubmit: edef <edef@edef.eu> Tested-by: BuildkiteCI
2023-10-28 r/6900 refactor(tvix/nix-compat/narinfo): return errorsFlorian Klink1-45/+127
This provides more info about where a NARInfo failed to parse, rather than just returning None and leaving a library user to manually debug. Change-Id: I9a28ddd8e5712101483ebe686fdc474c7bbc8e4e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9831 Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu>
2023-10-28 r/6899 refactor(nix-compat/nixbase32): clean up encodeedef1-16/+15
Change-Id: I63da5bd47cd9033e1cc13fbe4b4864514a5343cb Reviewed-on: https://cl.tvl.fyi/c/depot/+/9865 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6898 fix(nix-compat/nar/writer): `use ByteSlice` closer to call siteedef2-2/+2
Otherwise, it'll generate unused import warnings in release mode. Change-Id: I0399d2617a8a8b973a2b8c18f4a0a613d70c48f5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9864 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6897 feat(tvix/nix-compat): add narinfo parsing and serialisationedef3-1/+407
Change-Id: I72c63414794642ca8d85c3f635f49db888420c40 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9852 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6896 refactor(nix-compat/store_path): use nixbase32::decode_fixededef1-4/+2
Change-Id: I81471ee57920aa8fa889fb00c7903cdc570af9c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9863 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6895 feat(nix-compat/store_path): add StorePathRefedef1-22/+72
Change-Id: I0d888a55d93e5c22e77cb0264d09757656f731d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9862 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-27 r/6893 refactor(tvix): turn nullary enum variants into unit variantsedef2-16/+16
Change-Id: Iad4f2cb4aa92b5bb29ead6050348a8cd3e7b8632 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9860 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6892 refactor(nix-compat/store_path): speed up validate_name fast pathedef1-12/+39
Change-Id: Ie50b29145804777f7644952c65cb42519a8565e3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9859 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6891 feat(nix-compat/store_path): validate_name takes AsRef<[u8]>edef2-3/+4
Change-Id: I8819e2a7b63008a68f4f82035a08b960ac480dc3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9858 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6890 feat(nix-compat/store_path): validate_name over borrowed dataedef2-6/+10
Change-Id: Ifeb6231f48d4ad267a7acd398b4b3b687ee4d560 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9857 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6889 refactor(nix-compat/store_path): don't materialise fingerprintedef1-8/+9
Change-Id: I6a88531ded05c0dfb9232a0343a465fa02fb6989 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9856 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6888 refactor(nix-compat/store_path): make digest and name privateedef1-10/+12
Change-Id: I62cbe883afcf3dd0c8d4de0e3b845069eb750c97 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9855 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6887 fix(tvix/nix-compat): validate store path name lengthedef1-2/+13
Change-Id: I89ac0ad147a1872c021ab4235ca46ef3f51d0446 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9854 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-27 r/6886 fix(tvix/nix-compat): don't box CAHash::Textedef3-14/+9
Change-Id: I31df3909bc21c9038f9fb831879e60e541242819 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9853 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-27 r/6885 feat(tvix/nix-compat): add fixed-length base32 decodingedef1-1/+34
Change-Id: Iea9d51157c1e38e1734dc1ba752eba9b2372c61b Reviewed-on: https://cl.tvl.fyi/c/depot/+/9850 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6884 feat(tvix/nix-compat): use AsRef<[u8]> for base32 decode inputedef1-3/+5
Change-Id: If2275dda62b852aedb64b4f9915f7dc4173cabd2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9851 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-27 r/6883 refactor(tvix): condense long bytestringsedef4-62/+26
Change-Id: I3bea0827ec2c8db835334ce378a7bf3a39e9b1a3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9849 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-27 r/6882 feat(tvix/nix-compat): decode base32 with a lookup tableedef1-22/+42
This also takes input validation out of the loop, leaving the loop backedge as the sole branch in the hot path. Change-Id: Id08e6fb9cf5b074780efa09a7ad389352a601bcc Reviewed-on: https://cl.tvl.fyi/c/depot/+/9847 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-27 r/6881 refactor(tvix/nix-compat): clean up base32 decodingedef1-23/+18
Change-Id: I8591a3e1075f2281b7dc49f7fa9e0027062a78a5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9846 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-27 r/6880 refactor(tvix/nix-compat): simplify encode_lenedef1-6/+5
Change-Id: Idfefd3b5b0d1ffbd4e9208e634a2d9989965a291 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9845 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-23 r/6872 fix(nix-compat/src/derivation/validate): remove breakFlorian Klink1-2/+31
If the output was fixed, we broke out of the for loop too early, before actually validating individual outputs. Change-Id: I2259697dfa2a157764358f6d326a1f7f6610647c Reviewed-on: https://cl.tvl.fyi/c/depot/+/9815 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-10-23 r/6871 refactor(tvix/nix-compat): rename NixHashWithMode -> CAHashFlorian Klink9-204/+217
This specific struct is only used to represent content-addressed paths (in case a Derivation has a fixed-output hash, for example). Rename `Output`'s `hash_with_mode` to `ca_hash`. We now also include `CAHash::Text`, and update the `validate` function of the `Output` struct to reject text hashes there. This allows cleaning up the various output path calculation functions inside nix-compat/src/store_path/utils.rs, as they can now match on the type. `make_type` is renamed to `make_references_string`, `build_regular_ca_path` is renamed to `build_ca_path`, and `build_text_path` has a disclaimer added, because you might not actually want to use it. Change-Id: I674d065f2ed5c804012ddfed56e161ac49d23931 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9814 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-10-18 r/6857 test(tvix/nix-compat/nar/writer/sync): add testsFlorian Klink2-0/+136
Change-Id: I04c556e7b57f20dd33f71b0379e6104e1702a8ee Reviewed-on: https://cl.tvl.fyi/c/depot/+/9785 Reviewed-by: Connor Brewster <cbrewster@hey.com> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-18 r/6856 feat(tvix/nix-compat/nar/reader): add testsFlorian Klink5-0/+122
Change-Id: If0abaf74a3b7d201af8972e54e3e34b20b8c0bc4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9764 Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
2023-10-18 r/6855 fix(tvix/nix-compat/nar/wire): correct Node::Some doc commentedef1-1/+2
It is *eventually* followed by a Node, but there is some stuff in between. Change-Id: Ie7c7b462828bd3e066f4a7e774895f30b82763ef Reviewed-on: https://cl.tvl.fyi/c/depot/+/9768 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-18 r/6854 refactor(nix-compat/nar/writer): use clone_intoedef2-4/+2
Equivalent to the existing code, but a little less cryptic. Change-Id: Ib9b2f9aedddc84d0e79840bba4cce01f92d9bc56 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9766 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-18 r/6853 feat(tvix/nix-compat): NAR readeredef8-4/+530
Change-Id: I50d51baf62c0419eaf17f0dc262f728aaff9794d Reviewed-on: https://cl.tvl.fyi/c/depot/+/9688 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-10-18 r/6852 docs(tvix/nix-compat/nar): document the wire formatedef1-2/+66
Change-Id: I6c8e23bad27fa6ada1b8973482b4d99190cf050d Reviewed-on: https://cl.tvl.fyi/c/depot/+/9767 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-10-18 r/6851 refactor(tvix/nix-compat): use hash_with_mode's nix_hash_stringFlorian Klink1-7/+1
HashWithMode already provides a to_nix_hash_string() method, giving us exactly the string we need here. Change-Id: Id2635bf3ea6c2514faf3c26b297866d774f4ff4a Reviewed-on: https://cl.tvl.fyi/c/depot/+/9799 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-16 r/6841 refactor(tvix/nix-compat/derivation): remove some clonesFlorian Klink1-3/+9
Change-Id: Ie464467edfafd2050aa9e5fd0e07ff745cb15df8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9753 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com>
2023-10-16 r/6834 refactor(nix-compat/derivation): drop non_unicode testFlorian Klink1-81/+1
The previous CLs did already absorb all the logic into the common tests, no need to write this here again. Change-Id: I7ba84ba86d5445ed247e5d11d5e59b7fa815670e Reviewed-on: https://cl.tvl.fyi/c/depot/+/9732 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI
2023-10-16 r/6833 refactor(nix-compat/derivation): use ATerm for output_paths testFlorian Klink1-5/+13
Due to the lack of a ATerm parser, we were previously loading the JSON fixtures to construct our Derivation structs to run the output path calculations with. However, as we now have a ATerm parser, we can load the ATerm representation directly. This also means we can test the output path calculation for non-UTF8 Derivations. Change-Id: I0e53f41a23566b5ad5f0fed12724e02a10b02707 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9731 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
2023-10-16 r/6832 fix(nix-compat/derivation): handle dupsFlorian Klink2-23/+173
This now properly checks for duplicate output names in input derivation output names, and duplicate input sources. Change-Id: I0053854bfbf504f4f511fb3fe1a77a82b3aa61dd Reviewed-on: https://cl.tvl.fyi/c/depot/+/9738 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2023-10-16 r/6831 feat(nix-compat/{aterm,derivation}): init parserFlorian Klink11-3/+612
This provides a nom-based parser for Nix derivations in ATerm format, which can be reached via `Derivation::from_aterm_bytes`. Some of the lower-level ATerm primitives are moved into a (new) aterm module, and some more higher-level ones that construct derivation- specific types. Also, move the escape_bytes function into there, this is a generic ATerm thing. Change-Id: I2b03b8a1461c7ea2fcb8640c2fc3d1fa3ea719fb Reviewed-on: https://cl.tvl.fyi/c/depot/+/9730 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2023-10-16 r/6828 refactor(nix-compat/derivation): fix function nameFlorian Klink2-2/+2
typo: write_enviroment -> write_environment. Change-Id: I1a2dc826c0bf71f6ba97fe41c4d44619b5e6beff Reviewed-on: https://cl.tvl.fyi/c/depot/+/9739 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2023-10-16 r/6825 refactor(tvix/nix-compat): clippyFlorian Klink1-2/+2
Change-Id: I56282d9754b42e0e6cdbb08e9ae71f5700d28dd1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9747 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2023-10-15 r/6815 refactor(nix-compat/derivation): make write_environment more genericFlorian Klink1-5/+7
We don't actually care if it's a BTreeMap of strings, bstrings or any of that sort. The only thing we want to be able to do is get a reference to the bytes from the keys and values. Change-Id: I21b85811a9ea47fe06afa3108836ef9295e5d89b Reviewed-on: https://cl.tvl.fyi/c/depot/+/9737 Tested-by: BuildkiteCI Reviewed-by: edef <edef@edef.eu>
2023-10-15 r/6814 refactor(nix-compat/derivation): move test fixtures to subdirFlorian Klink21-10/+10
We use test_resources and globbing for some of the test cases, so adding additional files in there will also create new test cases, which we don't always want. Move it down one level to make some more space. Change-Id: I619867dc80a4ced59d45096d0703678663b559cd Reviewed-on: https://cl.tvl.fyi/c/depot/+/9729 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI
2023-10-15 r/6813 feat(tvix/nix-compat/nixhash/NixHashWithMode): from_algo_mode_hashFlorian Klink2-2/+48
Change-Id: Ieae628fab1926a498ae5c3eb27df1b722e6151d7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9728 Reviewed-by: edef <edef@edef.eu> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2023-10-15 r/6812 refactor(nix-compat/nixhash): add Result type aliasFlorian Klink1-6/+9
Change-Id: Id0248047e9642d38afc106629957a2e7608f8c78 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9727 Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
2023-10-15 r/6811 refactor(nix-compat/nixhash): box sha512Florian Klink1-4/+4
Limit the amount of memory consumed on the stack for NixHash. Sha512 isn't used that often, so it's fine if we heap-allocate it. Change-Id: I4a9eecd20c6184610124dc130c41bfa5d0dc04c5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9726 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Connor Brewster <cbrewster@hey.com>
2023-10-14 r/6808 refactor(tvix/nix-compat/derivation): fod_digest return [u8; 32]Florian Klink1-4/+4
This is of known length. Change-Id: Iba48ccc486d5bf9e38ec1a2da6e7b80997d2c6ca Reviewed-on: https://cl.tvl.fyi/c/depot/+/9723 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>