support unmodified nix >2.19
Our rust utilities currently rely on a libnixstore from harmonia, which links against nix_2_19.
This means the lila utilities work on nixos 24.05 but no longer on nixos-unstable, which since dropped 2.19
Unfortunately, harmonia has since removed the libnixstore component, so upgrading harmonia is not a solution.
There's several ways to resolve this situation:
- extract the relevant bits of
libnixstore(that targets nix libstore via C++ code) into our utilities - extract
libnixstorefrom before it was removed from harmonia and maintain it (and publish to crates.io) independently - extend the nix C API to support the bits we need (similar to https://github.com/NixOS/nix/pull/12044), and then use FFI with that C API from our utilities
The last approach seems most attractive, as the C API will longer-term also be the basis for other bindings. We may be able to use/extract Rust bindings to the C API from nixops4
The APIs relevant to us appear to be:
- hash_path
- query_path_info
- sign_string
- Radix::Base32
- query_references
I am also more favorable on binding to the C API because it is supposed to be stable and will thus require less maintenance.
(For now lila applies a patch to nix to expose the required library calls, which makes it work without further changes to the daemon, but means we'll be rebuilding nix. Let's keep this issue open for eventually upstreaming these changes and/or switching to a proper rust binding library instead of having our own - though I'm not planning to work on that in the near future)