Commit graph

12 commits

Author SHA1 Message Date
Robert Hensing
b3171585d1 Rename crates nix- -> nix-bindings-
This way, the crates can be published without interfering with
potential future non-bindings `nix-` crates, if Nix proper wants to
have native rust code, for instance.
2025-10-04 02:44:55 +02:00
Robert Hensing
3bef494271 fix: Add mutex to nix_util::settings to prevent concurrent access segfault
Fixes #106

The Nix settings system uses global mutable state without internal
synchronization. When multiple threads call settings::set concurrently
(as happens in parallel test execution), this causes a segfault in the
C++ std::set implementation.

Changes:
- Add mutex to serialize access through the Rust API
- Add documentation explaining thread safety limitations
- Add Once guard in nix-flake tests to minimize concurrent access

The mutex provides protection between Rust callers, though it cannot
completely prevent C++ Nix code from modifying settings concurrently.

(cherry picked from commit 203917657b60c4e1dcbaf442bec64c37c634abc4)
2025-10-04 02:31:16 +02:00
Taeer Bar-Yam
cc2e640e7f check_call!() macro to use () not []
(cherry picked from commit 66d255af0a5d331782dc24c89bb45d3434f3c109)
2025-10-04 02:31:16 +02:00
Robert Hensing
35803f4a30 refactor: Remove check_one_call
(cherry picked from commit 065f880e52c6d6cb44e4b857272176ebe2464eea)
2025-10-04 02:31:16 +02:00
Robert Hensing
bf6dbd3f1e fix: Do not duplicate ctx expr in check_call!
(cherry picked from commit 9b6f0c1e66d80ec2e92ce079152edb22c05e9b1e)
2025-10-04 02:31:16 +02:00
Robert Hensing
a6dbf17778 fix: Require mutable Context, as it should be
This spreads out transitively to many places and requires that
we use `check_call!` instead of `check_one_call` in a number of
places.

(cherry picked from commit 6bc31dcf206518a7be7f0ac6e773d5dfe25531ea)
2025-10-04 02:31:16 +02:00
Robert Hensing
2f3a5fb039 refact: Clean up Context interface to be safer
The mutation-based methods had some pitfalls, and we don't really
need them.

We could re-add them if we need to.

(cherry picked from commit ca92b8491d87cebf54dd2468599168fc7a16c07f)
2025-10-04 02:31:16 +02:00
Robert Hensing
1ac0f10f74 refact: Fix warning
(cherry picked from commit e9371a0838eec93a0158a408c58be1a1efd44ab2)
2025-10-04 02:30:46 +02:00
Robert Hensing
65f411d35e maint: Move conditionally unused use
(cherry picked from commit 21e3f3f569758b6cbf668c27330675c579efff5c)
2025-10-04 02:30:46 +02:00
Robert Hensing
4688ccbf95 refact: Make the callback convert to Result<String> immediately
This is slightly easier to use than the previous pattern that was
always followed up by the same conversions.

(cherry picked from commit 756c080730cd4fa81d4c0e3a99688cbe8debe57f)
2025-10-04 02:30:46 +02:00
Robert Hensing
6736f05a3f fix: Use function pointer for settings callback 2025-10-04 02:30:46 +02:00
Robert Hensing
daffade511 feat: nix_util::settings::set, get
(cherry picked from commit 19ed7bd655e72e10373f1afab5af214f2f47881e)
2025-10-04 02:30:46 +02:00