Skip to content

Replace config getters and store ops with nix-bindings-rust C API#1582

Draft
amaanq wants to merge 4 commits intoNixOS:masterfrom
obsidiansystems:nix-bindings-rust-integration
Draft

Replace config getters and store ops with nix-bindings-rust C API#1582
amaanq wants to merge 4 commits intoNixOS:masterfrom
obsidiansystems:nix-bindings-rust-integration

Conversation

@amaanq
Copy link
Copy Markdown
Member

@amaanq amaanq commented Mar 18, 2026

This PR replaces several C++ FFI functions with their nix-bindings-rust equivalents, using the Nix C API directly from Rust.

  • Config getters: get_store_dir, get_nix_version, get_this_system, get_extra_platforms, get_system_features, get_substituters, get_use_cgroups, set_verbosity replaced with nix_bindings_util::settings::get and nix_bindings_store::Store::open.
  • compute_fs_closure: replaced with nix_bindings_store::Store::get_fs_closure.
  • is_valid_path: replaced with nix_bindings_store::Store::is_valid_path.

@amaanq amaanq marked this pull request as draft March 18, 2026 05:02
@amaanq amaanq force-pushed the nix-bindings-rust-integration branch 3 times, most recently from ec59a76 to 734b093 Compare March 18, 2026 08:43
Copy link
Copy Markdown
Member

@artemist artemist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the is_valid_path changes are a good idea, just a minor nit.

I see the appeal of using settings from the bindings, but i'm not entirely happy with the level of type safety.


fn nix_setting_list(key: &str) -> Vec<String> {
nix_setting(key)
.split_whitespace()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we guarantee no values will have spaces? I am not confident there is a better way, though.

include_outputs: bool,
include_derivers: bool,
toposort: bool,
_toposort: bool,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If _toposort is not functional then we should not keep it as an argument. We should instead verify that if users are relying on it being toposorted then than the functional ready toposorts.

@amaanq amaanq force-pushed the nix-bindings-rust-integration branch 3 times, most recently from 6831e65 to 76975ea Compare March 25, 2026 01:01
…ctly from query

Callers went through `FfiRealisation.as_rust()` to deserialize the JSON
into a `Realisation` every time. Inlining that into the trait method
removes the wrapper struct, the unsafe Send/Sync impls, and the extra
conversion step at each call site.
@amaanq amaanq force-pushed the nix-bindings-rust-integration branch 6 times, most recently from 682f746 to 185d40a Compare March 25, 2026 04:39
@amaanq amaanq force-pushed the nix-bindings-rust-integration branch from 185d40a to 0094fe9 Compare March 25, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants