about summary refs log tree commit diff
path: root/users/Profpatsch/netencode
AgeCommit message (Collapse)AuthorFilesLines
2022-12-29 r/5543 chore(3p/sources): Bump channels & overlayssterni1-1/+1
The main change is that nixpkgs updated to GHC 9.2 and Stackage LTS-20, so we suffer from a bit of churn. * //3p/overlays/haskell: - use updated dhall-nix patch for hnix 0.16 - use superrecord fork with fixes for GHC 9.2 - use graphmod-1.4.5.1 which has support for GHC 9.2 * //users/Profpatsch: relax constraints on base in Haskell pkgs * //users/Profpatsch/cas-serve: inherit superrecord from 3p * //users/grfn/xanthous: - //3p/overlays/haskell for 8.10.7: * Provide missing dependency of binary-orphans. Fix already commited upstream as e238c3fdaab710a2ce0135e5a77cd7e6bb023a22, can be dropped when channel advances. * Downgrade to brick 0.71.1, the latest version xanthous supports. - Adjust to generic-arbitrary >= 1.0, providing Arg constraints where necessary. - Increase constraint-solver-iterations to 6 (default 4), so Xanthous.Command and Xanthous.Data can be typechecked. - Drop NFData instances for Key and Modifier which have been added to vty upstream. Change-Id: I2170438c2ce8130b65f1a9fe07c4fecab5683d66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7654 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2022-09-25 r/4966 feat(users/Profpatsch/netencode.rs): parse multiple stdin valuesProfpatsch3-30/+103
Adds support for parsing multiple netencode values from stdin. This is overly complicated for my tastes, but I don’t see a better way of writing this logic that does not read all of stdin before starting to parse the first value. A kingdom for a conduit. Change-Id: Ia4f849d4096c43e887756b756d2a85d7f9cd380a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6631 Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2022-09-01 r/4564 docs(users/Profpatsch/netencode): add docstrings to Netencode.hsProfpatsch1-3/+46
Change-Id: I509ea7949990e8c652133bd9ef21243a41f58e44 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6202 Reviewed-by: Profpatsch <mail@profpatsch.de> Autosubmit: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2022-08-22 r/4445 feat(users/Profpatsch): init netencode-hsProfpatsch3-0/+445
Haskell implementation of the netncode parser & generators. Change-Id: I904df752e78641110af2857e71d8206bf432d427 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6114 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-07-01 r/4270 docs(users/Profpatsch/netencode): Parser security considerationsProfpatsch1-0/+18
Netencode parsers should probably set an upper length limit. Change-Id: Ibe65f2b59058106b720867a83435bf45660f1adf Reviewed-on: https://cl.tvl.fyi/c/depot/+/5908 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2022-02-14 r/3822 feat(users/Profpatsch/netencode): ignore earlier record entriesProfpatsch2-6/+8
It turns out that the netencode spec requiring to ignore *later* entries meant that every parser has to do an extra check for each element, instead of just overriding the key in the hash map. This leads to a situation where the simple implementation is the wrong one, which would lead to very subtle problems in parsers (see also the infamous “json duplicate record entry” problem which has been used for various exploits in the past). To be fair, exploits are still possible, but at least a `Map.fromList` will be the right implementation (provided it folds from the left) now instead of the wrong one. Examples of the trivial implementation being now right: Python: > dict([("foo", 1), ("foo", 2)]) {'foo': 2} Rust: > println!("{:?}", HashMap::from([ ("foo", 1), ("foo", 2) ])); {"foo": 2} Haskell: > Data.Map.fromList [ ("foo", 1), ("foo", 2) ] fromList [("foo",2)] Change-Id: Ife9593956f4718e5e720f4f348c227e4f3a71e2d Reviewed-on: https://cl.tvl.fyi/c/depot/+/5108 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: Profpatsch <mail@profpatsch.de>
2022-02-08 r/3791 style(rust): Format all Rust code with rustfmtVincent Ambo3-275/+346
Change-Id: Iab7e00cc26a4f9727d3ab98691ef379921a33052 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5240 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: grfn <grfn@gws.fyi> Reviewed-by: tazjin <tazjin@tvl.su>
2022-01-31 r/3723 style: format entire depot with nixpkgs-fmtVincent Ambo2-65/+80
This CL can be used to compare the style of nixpkgs-fmt against other formatters (nixpkgs, alejandra). Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: cynthia <cynthia@tvl.fyi> Reviewed-by: edef <edef@edef.eu> Reviewed-by: eta <tvl@eta.st> Reviewed-by: grfn <grfn@gws.fyi>
2021-11-23 r/3088 refactor(readTree): Move 'drvTargets' into readTreeVincent Ambo1-1/+1
This function is also generally useful for readTree consumers that have the concept of subtargets. Change-Id: Ic7fc03380dec6953fb288763a28e50ab3624d233
2021-11-13 r/3051 docs(users/Profpatsch/netencode): fix typoProfpatsch1-1/+1
Change-Id: I7edb9027c0a9eb014931033760be5f3d6e734b8a Reviewed-on: https://cl.tvl.fyi/c/depot/+/3845 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-11-13 r/3041 docs(users/Profpatsch/netencode): some docstringsProfpatsch1-0/+10
Change-Id: I447113d408cf51f1ed9f9d7571b2229e166e7680 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3281 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-05-17 r/2594 fix(nix/writers/rust): remove args overrideProfpatsch1-2/+0
We can be closed world, so let’s restrict the arguments to the subset we need for now. The existing override was wrong, in that `// args` would use the arguments we already added, again. So instead of deliberating about how to make this work right in all cases, we don’t need it, we trim it. Change-Id: I6443a0808b8bfd5e4db939b669c6afc741954db8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3057 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2021-04-30 r/2554 fix(users/Profpatsch/netencode): use write_all in encoderProfpatsch1-4/+4
`write` returns the written usize; now I wonder why rustc didn’t at least produce a warning because the result was unused. Do we need to add any flags to `rustSimple`? Change-Id: If8d51d95c993dec6c92e46dbc82cd8cdd398f441 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3056 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
2021-04-24 r/2547 chore(nix): move rustSimple from users.Profpatsch.writersProfpatsch1-12/+7
I think it’s solid enough to use in a wider context. Change-Id: If53e8bbb6b90fa88d73fb42730db470e822ea182 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3055 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: lukegb <lukegb@tvl.fyi>
2021-04-23 r/2545 feat(users/Profpatsch/lib): add eprint-stdin-netencodeProfpatsch1-3/+3
Like `eprint-stdin`, but reads stdin as netencode and pretty-prints it to stderr. Change-Id: I430c010b0cac45f077cde9dadfd79adfa7a53eca Reviewed-on: https://cl.tvl.fyi/c/depot/+/2533 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-04-23 r/2544 feat(users/Profpatsch/netencode): add pretty printerProfpatsch2-0/+172
Simple pretty printer for netencode values, as a rust library and an accompanying command line tool which takes netencode on stdin and prints the pretty version to stdout. Change-Id: I0a57c644985162bc08a9bf1ee78f7be278400199 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2532 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-04-23 r/2543 feat(users/Profpatsch/netencode): add env-splice-recordProfpatsch2-8/+37
It’s the inverse of record-splice-env! It sucks up the environment and prints it as a netencode dict! Only the utf-8 clean parts at least. Change-Id: I96c19fc5ea3a67a23e238f15f4d0fa783081859c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2527 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-04-04 r/2434 feat(users/Profpatsch/writers): make testing default for rustSimpleProfpatsch1-3/+2
This way we don’t have to explicitely wrap the rust crate with a `testRustSimple`, but it will be done automatically, unless `doCheck` is set to `false`. Change-Id: I32a81821eeff620e7da57332b0873495bb85a843 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2841 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: sterni <sternenseemann@systemli.org>
2021-04-03 r/2419 chore: move all 3p buildRustCrate derivations to //third_partysterni1-40/+2
Profpatsch and me are basically the only users of depot.users.Profpatsch.writers.rustSimple*. To pull in the odd dependency we usually use buildRustCrate which is rather convenient. However we've picked up the bad habit of inlining these in a let somewhere instead of managing them in a more central location although there has been an (unsuccesful) attempt at this in //users/Profpatsch/rust-crates.nix. This CL moves all buildRustCrate based derivations into third_party.rust-crates and deletes any duplicate derivations we have accumulated in the tree. Change-Id: I8f68b95ebd546708e9af07dca36d72dba9ca8c77 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2769 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-04-01 r/2382 feat(users/Profpatsch/netencode): fully streaming parserProfpatsch1-39/+95
In order to arbitrarily split netencode over multiple reads, we need to make the parser completely streaming, so that it recognizes all cases where it needs more input. Luckily, this is fairly trivial, after working around a bunch of overeager parsing. The tricky part was the giant `alt`, where inner parsers would start consuming input and thus become incomplete when they fail afterwards. Sinc the format *always* starts the different types with one discriminator char, we can use that to instantly return the parser and try the next one instead. The other tricky part was that lists and records would parse all inner elements and then choke on the empty string after the last element, because the inner parser would consume at least the descriminator, and an empty string is always `Incomplete`. We wrap these into a small combinator which plays nice with `many0` in that regard. Change-Id: Ib8d15d9a7cab19d432c6b24a35fcad6a5a72b246 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2704 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: sterni <sternenseemann@systemli.org>
2021-03-15 r/2282 feat(users/Profpatsch): build attrset members on CIsterni1-1/+1
Setting meta.targets to include all derivations in the different package sets in Profpatsch's user folder makes them checked by CI until they do the readTree refactor as promised. To reduce code duplication we handle this in a simple function which is exposed from nix.utils which may be a good place for depot specific bits and bops we accumulate over time. To get around the issue of too nested sets we perform the following renames: * users.Profpatsch.tests gets moved into its own directory * users.Profpatsch.arglib.netencode now lives in its own file instead of the default.nix * users.Profpatsch.netstring.tests gets moved into its own directory Change-Id: Icd039c29d7760a711c1c53554504d6b0cd19e120 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2603 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-18 r/2219 chore(users/Profpatsch/netencode): update serdesterni1-4/+4
Was messing around with serde and trying to build serde_json something, might as well commit this. Change-Id: I60f87aa3180f750fa171eca7f9c375ed053f8456 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2537 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-14 r/2216 feat(users/Profpatsch/netencode-rs): run tests with testRustSimplesterni1-15/+10
The rust tests are now automatically built and run if users.Profpatsch.netencode-rs is built without changing the content of its output. users.Profpatsch.netencode-rs-tests has been removed in favor of this, but can still be accessed as builtins.head users.Profpatsch.netencode.netencode-rs.drvDeps Change-Id: I25e8191f5b9efa08ace4a584a75978565c79d8d0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2530 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-13 r/2213 fix(users/Profpatsch/netencode/gen/dwim): support derivationsProfpatsch1-5/+9
We forgot the special casing of derivations; if we recurse into a derivation like we’d recurse into an attrset, it always ends in tears, so dwim will just print the derivation path instead, which is usually what you want anyway. Change-Id: Ieed1b68dfcf8f2925ee3a75ae4f460fa5081da28 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2526 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2021-02-13 r/2211 chore(users/Profpatsch/netencode): move nom dependencies to pkgsetProfpatsch1-23/+1
Change-Id: I7393f60e4b29f24399d681d4546ac35140650d1a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2524 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-13 r/2210 feat(users/Profpatsch/netencode/record-splice-env): ignore non-scalProfpatsch1-3/+8
The headers are not a scalar, so record-splice-env doesn’t know how to convert them to an envvar; let’s just ignore everything that can’t be converted to a scalar for now. Change-Id: I74ed0aa942fcd26beb058705830bc2f2b516e93e Reviewed-on: https://cl.tvl.fyi/c/depot/+/2523 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-13 r/2209 feat(users/Profpatsch/netencode): add dec::TryProfpatsch1-5/+13
Tries to decode the inner type, turning it into an Option. Change-Id: I29d1286fe873c28d7c4a4b71f220acaf2d23f8e1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2522 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-13 r/2207 feat(users/Profpatsch/execline/exec_helpers): add args()Profpatsch1-1/+1
Some programs need an exact amount of arguments, and we want to fail if they get too many or not enough. Change-Id: Ic703949f38780718f26118b896e7c7d7aa5553d9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2504 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-13 r/2205 feat(users/Profpatsch/netencode): add record-getProfpatsch1-0/+30
Projecting into one record field of netencode given on stdin. Change-Id: I975bd5558a06988aa159156ca73a449710db983f Reviewed-on: https://cl.tvl.fyi/c/depot/+/2502 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-09 r/2194 feat(users/Profpatsch/netencode): add dec::{Text,Binary,OneOf}Profpatsch1-6/+60
`Text` and `Binary` should be self-explaining, they just match on the primitive and throw an error otherwise. OneOf is cool, because it allows the user to match on the result type of decoding `inner`, and give a list of values that should be allowed as the result type (the associated type `A` in the `Decoder` trait). Change-Id: Ia252e25194610555c17c37640a96953142f0a165 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2498 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-09 r/2193 fix(users/Profpatsch/netencode/gen: fix number generatorProfpatsch1-2/+2
Shouldn’t use the netstring function, since that adds the length of the containing string, which doesn’t make sense for numbers, they just have their one length number and content. Change-Id: I5591f6dd59154c5ef38d6e9b7300d19884a2d57b Reviewed-on: https://cl.tvl.fyi/c/depot/+/2497 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-09 r/2192 feat(users/Profpatsch/arglib): use exec_helpers for rustProfpatsch1-1/+1
Change-Id: I3056385eb11e45ae13456f4c47052651ba5fb62f Reviewed-on: https://cl.tvl.fyi/c/depot/+/2496 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-09 r/2191 feat(users/Profpatsch/netencode): add `U::to_t()`Profpatsch1-7/+32
This fell out of us moving the `U::List` to a `Vec`. I noticed that now we have deep recursion for `U`s, which originally wasn’t intended; reverting to contain `&[u8]` might be a good experiment, as long as the lists stay a `Vec<&'a [u8]`, which was the thing preventing us from parsing lists without allocating memory. Change-Id: I4900c5dea460fa69a78ce0dbed5708495af5d2e1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2495 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-09 r/2190 feat(users/Profpatsch/netencode): add `dec::RecordDot`Profpatsch2-6/+29
`dec::RecordDot` accesses a specific field of a netencode record. In order to implement this, either we’d have to introduce a type-level string, but in all honesty this kind of typelevel circlejerking never leads anywhere, so let’s change the trait to use `&self` after all. Usage is pretty much the same, except actually more like you’d expect. Change-Id: I5a7f1a3f587256c50df1b65c2969e5a7194bba70 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2494 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-09 r/2189 feat(users/Profpatsch/netencode): add `dec::AnyU` as idProfpatsch1-0/+26
Change-Id: I3037882dff15243bd7a5c1c78331f8e2ffdbda84 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2493 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2021-02-06 r/2188 feat(users/Profpatsch/netencode): decode from UProfpatsch2-27/+28
Since we don’t necessarily need to decode deeply, we can make the decoders take a `U` instead of a `T`. Change-Id: I9704a21edb3922d58411e6807d027d684b18d390 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2492 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-06 r/2187 feat(users/Profpatsch/netencode): `encode()` impl for T and UProfpatsch1-4/+45
Also change the toplevel `encode()` to take a `&U` instead of an owned `U`. Change-Id: I8e51540cc531e70ae1c94e3676f4dd88da7a924d Reviewed-on: https://cl.tvl.fyi/c/depot/+/2491 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-06 r/2186 feat(users/Profpatsch/{netencode,http-parse}): use HashMapProfpatsch1-8/+9
`U::Record` is required to be a hash map (later keys should be ignored), so why not do the hash map immediately. This surfaced a problem with read-http, because duplicate headers in http are possible, but before they’d be silently ignored. Now we merge them into a `U::List` in case, to be handled by consumers of read-http. Change-Id: Ifd594916f76e5acf9d08e705e0dec2c10a0081c9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2490 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-06 r/2184 feat(users/Profpatsch/netencode): nest Us in U::ListProfpatsch1-32/+18
Earlier we left the next level of values unencoded, since lists are just concatenated netencode values. But I noticed that you can’t write e.g. a `t_to_u` function, because only in the case of lists you need to allocate memory. Turns out that if we read the next level of values, everything is handled the same as in `Record` and things suddenly start working. We can also throw away some of the strange and ad-hoc parser helpers we needed before, `skip` and `list_take`, since now those are just normal `Vec::iter().skip()` and take. Change-Id: Ibc476e028102944a65c2b64621047086cfc09aa5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2488 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2021-02-06 r/2183 fix(users/Profpatsch/netencode): decode U::Text directly into strProfpatsch1-11/+11
Since `Text` is a scalar, it doesn’t make sense to delay the utf-8 verification to the consumer. Change-Id: I36e4d228fbf35374d7c1addb4b24828cf6e927e5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2478 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-06 r/2181 fix(users/Profpatsch/netencode-rs-tests): reflect changed T::List typesterni1-1/+1
a044a870849d03b3a71df17e589112e0c228a06e removed boxes in T::List, but the tests were not adjusted accordingly. Seems like netencode fell victim to CI not recursing into attrsets not generated by readTree in pipeline generation. Change-Id: I65d58a82881059983f7d6bc7a32263c6671ccbba Reviewed-on: https://cl.tvl.fyi/c/depot/+/2486 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2021-02-06 r/2180 fix(users/Profpatsch/netencode_mustache): add arglib crate to depssterni1-0/+1
Seems like 5d44df3af65767e731c0dd239bd1d9664edbb361 forgot to add the newly split out crate to the dependencies of netencode_mustache. CI didn't pick up on it since it is hidden away from readTree in an attrset in a file. Change-Id: I7df9a636d849de48a99562d1cda8c0e6765f4781 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2485 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-31 r/2176 feat(users/Profpatsch): add die_* helpers for semantic exit errorsProfpatsch2-6/+10
There is this semantic exit code schema championed by execline and skaware tooling, and we refined and documented it a bit in lorri https://github.com/nix-community/lorri/blob/d1d673d42090f0cfe8ab9b92b465315a9e7d30a3/src/ops/mod.rs#L24-L35 in the past. This just transcribes the error messages into simple helper functions. Applies the functions to the places where we would panic or die `sys::exit()` instead. Change-Id: I15ca05cd6f99a25a3378518be94110eab416354e Reviewed-on: https://cl.tvl.fyi/c/depot/+/2475 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-31 r/2175 feat(users/Profpatsch/execline): add args_for_execProfpatsch1-9/+8
`exec_into_args` would just read argv and exec into it, but we want to be able to write commands which take some positional arguments first. Thus we split the invocation into `args_for_exec`, which returns the positional arguments and prog, and then pass prog to `exec_into_args` when we want to exec eventually (prog is still an iterator at this point). Change-Id: I0b180c1a100b96363fe33ba2c42034ed41716b7a Reviewed-on: https://cl.tvl.fyi/c/depot/+/2474 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-31 r/2173 feat(users/Profpatsch/netencode): add record-splice-envProfpatsch1-0/+25
Splice a netencode record from stdin into the environment. Change-Id: I7eac19e18164e070e4463ee431d9b0e955857b9c Reviewed-on: https://cl.tvl.fyi/c/depot/+/2454 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-31 r/2172 feat(users/Profpatsch/netencode): add decoder moduleProfpatsch1-0/+46
Decoders are implemented not directly on output types, but on trivial proxy types, so that we can easily combine those into a decoder, and then the associated type is the actual return value of the decoder. Change-Id: Ibce98fa09fc944e02ab327112ec7ffbc09815830 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2455 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-31 r/2170 refactor(users/Profpatsch/netencode): rust read from stdin helperProfpatsch1-1/+13
Change-Id: I195c0212e224f676de5db37807731b814f99e818 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2452 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-31 r/2167 refactor(users/Profpatsch): move arglib_netencode into its own libProfpatsch1-21/+3
arglib is the simple idea of passing structured data via a conventional environment variable instead of implementing an optparser for every little tool. Pop the envvar, decode the contents, return the contents. Change-Id: Ie44148293a58aae9a0a613895176227d43b491bb Reviewed-on: https://cl.tvl.fyi/c/depot/+/2449 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-27 r/2149 chore(users/Profpatsch/netencode): netencode.nix -> gen.nixProfpatsch2-2/+2
Change-Id: I7ccbfe863fbff65015caa8c740b80c4bb5c59dc1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2446 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
2021-01-27 r/2148 feat(users/Profpatsch/netencode): add dwim function to nix genProfpatsch1-1/+17
Basically what you expect, strings to text, ints to 64-bit integers, attrs and lists to nested records and lists. Change-Id: I9d3d841f32ab32a152cd61522f02ebde4a9b11d3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2444 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI