lucab / libsystemd-rs

A pure-Rust client library to work with systemd
https://crates.io/crates/libsystemd
Other
105 stars 19 forks source link

Remove nix dependency #105

Closed swsnr closed 2 years ago

swsnr commented 2 years ago

Builds upon #104.

I realized that we're not really using a lot of nix, so I figured we could just drop the dependency with only a few extra pieces of unsafe code. nix is pretty heavy-weight, and contributes quite a bit to build times, especially in downstream crates which can often end up with multiple copies of nix in the dependency tree. The less the better I think :slightly_smiling_face:

Most things we used were just direct wrappers around the C API; replacing them adds a bit of unsafety but all these functions and patterns are well-understood.

Only the cmsg stuff for sending the memfd to journald is pretty involved, however I've written that before for the tracing-journald implementation (where nix was not an option) so it wasn't much work.

I added SAFETY annotations for all unsafe instances, which hopefully explain what's going on.

Personally I believe that reducing dependencies is always good, so I feel this pull request is worth the additional code, but I understand that there are different opinions about this, so please do feel free to close right away if you think it's not worth it.

swsnr commented 2 years ago

@lucab I'm closing this MR, as per our discussion in #106 :slightly_smiling_face: