tweag / nix-remote-rust

MIT License
31 stars 1 forks source link

Remaining operations to serialize to reach a baseline of Nix 2.18 #3

Open lf- opened 4 months ago

lf- commented 4 months ago

Hi! I'm writing as one of the maintainers of Lix. I was originally looking at this library to see if it was about to cause compatibility problems by using obsolete methods by accident but it doesn't use any of the obsolete methods (which were not really carefully comprehensively written down as such before we looked into it)! Fantastic work!

If it's useful to you, we have a slightly cleaner list of methods and their deprecation status than CppNix has, here: https://github.com/lix-project/lix/blob/4ac2c496d499a4a0e2d64edf32eb855268e7aa8d/src/libstore/worker-protocol.hh#L140-L185

We are doing initial research to potentially use this library in our project to replace the Nix protocol, by putting it in a rust shim. If we wind up going ahead with this plan, we would probably contribute these, so I would not strongly prioritize implementing them yourself. Nonetheless, here are the not-yet-implemented methods that one would have to implement to reach a 100% 2.18 no-legacy compatibility baseline:

The only remaining question is how much of import happened since proto 34 (which is the one supported by this project per the blog post) and proto 35 (CppNix 2.18). As far as I can tell, that is just:

https://github.com/lix-project/lix/blob/50472aa5bea95b9e800df833f4f7ec7691e63807/src/libstore/daemon.cc#L1018-L1026

Given that, it looks like this library is almost ideal for our use case already (assuming the tests are good; but we can potentially help if we decide to use it), and that's absolutely brilliant information to find out. Genuinely, thank you so much for writing it.

jneem commented 4 months ago

Thanks for the interest! We can definitely add those three missing ops (I'm a bit puzzled how we missed them, actually! I thought we'd done all the non-obsolete ones...)

Compatibility with proto 35 also looks straightforward, I agree.

Automatic testing is, sadly, almost nonexistent right now. We have a bunch of shell scripts (not committed to the repo) that we've been running manually to test our proxy against an actual CppNix daemon. I'll see if I can wrangle them into an automatic test suite.

lf- commented 4 months ago

I'm not sure if you have seen it, but there is a fair amount of test coverage of the serializers in CppNix with binary test files. We didn't forward-port a number of the changes to it post-2.18, so that section is likely most comprehensive in CppNix here: https://github.com/nixos/nix/blob/7c2981fc559e93131c845164907cec6cae11ce48/tests/unit/libstore/worker-protocol.cc#L72-L93

My suggestion for writing a test suite for this library as a former rust-analyzer dev is to steal some of their ideas (:P):

That should be useful for building confidence that the library is equivalent to the CppNix one. We can help out with testing work when we get to protocol work in the next few months.

jneem commented 4 months ago

Thanks for the tips! I got the first point working, and I'll look at arbtest (or maybe proptest, which I'm already familiar with) next.

I think our shell script end-to-end tests are still useful, and I'll try to get them cleaned up as well. For example, they test that we're correctly tagging the return type of each worker op.

Ericson2314 commented 4 months ago

I wrote the round trip characterization tests with the explicit idea that the golden masters can be reused for other implementations ;)

jneem commented 4 months ago

I looked into the missing ops:

So based on these, I think we decided that those two were obsolete. Our definition of "obsolete" was "we can't make a new nix client produce those ops."

AddIndirectRoot seems to be missing because it's only used over uds and we only tested over ssh. That one's trivial to add, though.