about summary refs log tree commit diff
path: root/tvix/nix-compat
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-04-08T08·31+0300
committerclbot <clbot@tvl.fyi>2024-04-08T08·40+0000
commitc05f90e611c9e0e74fbedeff97cf6ca768264d64 (patch)
treee4a19ed322bf9bd031db6ebf226bb138beadfb41 /tvix/nix-compat
parentfd749070e29bd3856e5923136ea97260d933e3db (diff)
refactor(tvix/nix-compat/wire): express magics as u64 r/7875
This allows using read_u64, write_u64, which is a bit easier to juggle
with.

Also, update names to align with the nix codebase, which makes it easier
to spot both the constant name as well as the value.
Leave the ASCII interpretation as a comment afterwards.

Change-Id: I0b9ab187acd22807e2785b0722aa4300dab37c51
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11378
Tested-by: BuildkiteCI
Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r--tvix/nix-compat/src/wire/worker_protocol.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/tvix/nix-compat/src/wire/worker_protocol.rs b/tvix/nix-compat/src/wire/worker_protocol.rs
index c9d055319273..121b9b2ea5cb 100644
--- a/tvix/nix-compat/src/wire/worker_protocol.rs
+++ b/tvix/nix-compat/src/wire/worker_protocol.rs
@@ -11,14 +11,11 @@ use crate::wire::primitive;
 
 use super::bytes::read_string;
 
-// LE-encoded nixc on 64 bits. Because why not.
-pub static MAGIC_HELLO: [u8; 8] = *b"cxin\0\0\0\0";
-// LE-encoded dxio on 64 bits. What's dxio? I have no clue.
-pub static MAGIC_HELLO_RESPONSE: [u8; 8] = *b"oixd\0\0\0\0";
-// LE-encoded protocol version.
-pub static PROTOCOL_VERSION: [u8; 8] = [0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
-
-pub static STDERR_LAST: u64 = 0x616c7473;
+pub static WORKER_MAGIC_1: u64 = 0x6e697863; // "nixc"
+pub static WORKER_MAGIC_2: u64 = 0x6478696f; // "dxio"
+pub static STDERR_LAST: u64 = 0x616c7473; // "alts"
+/// Protocol version (1.35)
+pub static PROTOCOL_VERSION: u64 = 1 << 8 | 35;
 
 /// Max length of a Nix setting name/value. In bytes.
 ///