chore(tvix/nix-daemon): Implement STDERR_READ protocol

When sending nars over the wire to the nix-daemon, nix protocol versions
1.21 to 1.23 use this framing protocol.

This change implements an AsyncRead for this protocol, to be used in
AddToStoreNar and any other operations when necessary.

Change-Id: I571f1adbb2343c14c98503d1a2c12eea4c783ec9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12813
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Vova Kryachko 2024-11-19 12:28:42 -05:00 committed by Vladimir Kryachko
parent e5fbde94aa
commit db13b6c092
5 changed files with 400 additions and 3 deletions

View file

@ -53,9 +53,9 @@ Normal string log message.
### `STDERR_READ`
Reader interface used by ImportsPaths and AddToStoreNar (between 1.21 and 1.23).
It works by sending a desired buffer length and then on the receiver stream it
reads bytes buffer of that length. If it receives 0 bytes it sees this as an
unexpected EOF.
It works by sending a *desired* buffer length and then on the receiver stream it
reads the *actual* buffer length followed by a bytes buffer of that length padded to
8 bytes. If it receives 0 bytes it sees this as an unexpected EOF.
- 0x64617461 :: [UInt64][se-UInt64] (hardcoded, 'data' in ASCII)
- desiredLen :: [Size][se-Size]