Commit graph

23 commits

Author SHA1 Message Date
Profpatsch
72924facae fix(nix/writers/rust): remove args override
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-05-17 23:00:57 +00:00
Profpatsch
eb41eef612 chore(nix): move rustSimple from users.Profpatsch.writers
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-24 10:23:55 +00:00
Profpatsch
c98dd8b352 feat(users/Profpatsch/lib): add eprint-stdin-netencode
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 20:45:28 +00:00
Profpatsch
5ca71308a8 feat(users/Profpatsch/netencode): add pretty printer
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 20:45:28 +00:00
Profpatsch
9d7c3ee877 feat(users/Profpatsch/netencode): add env-splice-record
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-23 20:45:28 +00:00
Profpatsch
e7c78570ed feat(users/Profpatsch/writers): make testing default for rustSimple
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-04 15:16:23 +00:00
sterni
0133fdc737 chore: move all 3p buildRustCrate derivations to //third_party
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-03 22:16:35 +00:00
sterni
5d8490d2fc feat(users/Profpatsch): build attrset members on CI
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-03-15 22:16:19 +00:00
sterni
ee9da33576 chore(users/Profpatsch/netencode): update serde
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-18 19:42:21 +00:00
sterni
f8c92f4118 feat(users/Profpatsch/netencode-rs): run tests with testRustSimple
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-14 12:40:06 +00:00
Profpatsch
d6bca70840 chore(users/Profpatsch/netencode): move nom dependencies to pkgset
Change-Id: I7393f60e4b29f24399d681d4546ac35140650d1a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2524
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-02-13 20:00:23 +00:00
Profpatsch
708f17d49b feat(users/Profpatsch/netencode/record-splice-env): ignore non-scal
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 20:00:23 +00:00
Profpatsch
81122c1297 feat(users/Profpatsch/execline/exec_helpers): add args()
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 20:00:23 +00:00
Profpatsch
1e5baa0dea feat(users/Profpatsch/netencode): add record-get
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-13 20:00:23 +00:00
Profpatsch
7d9c30ab3d feat(users/Profpatsch/netencode): add dec::RecordDot
`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 01:36:27 +00:00
Profpatsch
3faf5b6f09 feat(users/Profpatsch/netencode): decode from U
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 22:29:21 +00:00
sterni
716bbb70f9 fix(users/Profpatsch/netencode_mustache): add arglib crate to deps
Seems like 5d44df3af6 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-02-06 17:51:51 +00:00
Profpatsch
492b79ec7a feat(users/Profpatsch): add die_* helpers for semantic exit errors
There is this semantic exit code schema championed by execline and
skaware tooling, and we refined and documented it a bit in lorri
d1d673d420/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 16:06:25 +00:00
Profpatsch
83634341aa feat(users/Profpatsch/execline): add args_for_exec
`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 16:06:25 +00:00
Profpatsch
cf3aab3b78 feat(users/Profpatsch/netencode): add record-splice-env
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 11:10:00 +00:00
Profpatsch
f68781da1b chore(users/Profpatsch/netencode): netencode.nix -> gen.nix
Change-Id: I7ccbfe863fbff65015caa8c740b80c4bb5c59dc1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2446
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
2021-01-27 13:41:18 +00:00
Profpatsch
27a73171cf feat(Profpatsch/netencode): add netencode-mustache
A little executable, combining the netencode and mustache libraries to
make easy templating from the command line possible.

Combined with the nix netencode generators, it’s now trivial to
populate a mustache template with (nearly) arbitrary data.

Yay.

Change-Id: I5b892c38fbc33dd826a26174dd9567f0b72e6322
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2320
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
2021-01-03 16:29:57 +00:00
Profpatsch
f1c38e2560 feat(Profpatsch): dump netencode spec & parser
The netencode standard, a no-nonsense extension of netstrings for
structured data.

Includes a nix generator module and a rust parsing library.

Imported from
e409df3861/pkgs/profpatsch/netencode

Original license GPLv3, but I’m the sole author, so I transfer it to
whatever license depot uses.

Change-Id: I4f6fa97120a0fd861eeef35085a3dd642ab7c407
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2319
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
2021-01-03 16:29:57 +00:00