Commit graph

33 commits

Author SHA1 Message Date
Robert Hensing
f7d4499ab2 fix: Use c_char where appropriate
This builds on the previous commit to make it compatible with the
currently locked build configuration.

(cherry picked from commit bd1edec2fa5251263c768c3e2b312eb4f21d2bb4)
2025-10-04 02:31:17 +02:00
Tristan Ross
c924fed81b fix: rust types
(cherry picked from commit 925a0abd694f6409b6d54b6cad3a61fc916215d3)
2025-10-04 02:31:16 +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
Robert Hensing
b3a80dd36e maint: Remove Cargo.toml patch constraints
(cherry picked from commit 155550be6a8487771ddb67d09f3eba829e54e622)
2025-10-04 02:31:16 +02:00
Robert Hensing
895336ac79 License as LGPL-2.1
(cherry picked from commit 1127742e387ef78b91ec1e4cec0bb17b5e85666c)
2025-10-04 02:31:16 +02:00
Robert Hensing
1e3cce7742 refact: Resolve some clippy warnings
(cherry picked from commit dc4bfaa993eb2d712d53f70551db9ac34b0cda08)
2025-10-04 02:31:16 +02:00
Robert Hensing
d40bbbed88 maint: Update Nix
(cherry picked from commit 203f5d519369235097fef2bdaefa6b3d0f5e963b)
2025-10-04 02:31:16 +02:00
Robert Hensing
69d4ccc422 fix: Temporarily revert Nix to recover getFlake
https://github.com/NixOS/nix/issues/11399
(cherry picked from commit 0f2ae7d080dda34938517f781b4eb436522e9d65)
2025-10-04 02:31:16 +02:00
Robert Hensing
9213c9a5a0 feat: Make Cargo.toml source locations explicit
This allows cargo metadata to operate on it without adding the
source files to the build. (A choice which will save a few rebuilds
of the manual)

(cherry picked from commit 1779295f3e13cc15f8422d52a3753bb927ac8fa7)
2025-10-04 02:31:16 +02:00
Robert Hensing
eb0595226d doc: Context
(cherry picked from commit 976ecda38530d57b872c20eaeab5d3631076140b)
2025-10-04 02:31:16 +02:00
Robert Hensing
ee1d591e1a fix: Update for more recent Nix API
(cherry picked from commit 55355f03ab86dfa15972681d9a51d333739f6d10)
2025-10-04 02:31:16 +02:00
Taeer Bar-Yam
c235b32868 check_call_opt_key: [] -> ()
(cherry picked from commit 76966c24dcf6413a4ebdfe0ddba00e3d1d7e5fff)
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
da26721bea fix: Do not duplicate ctx expr in check_call_opt_key!
(cherry picked from commit 86ddc63a573cd08ec19008448ec2fca33a84159e)
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
870c03ee4d fix: Revert hiding of Context::ptr, add check_call_opt_key
(cherry picked from commit 5fba79143c85177d1649aa97d70ece067bade0fd)
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
Taeer Bar-Yam
226639939f feat: nix_util::context::check_call!(func[...])
> I couldn't figure out a way to use () for the function call, but I didn't try that hard.

I (Robert) have also given it a shot, briefly, unsuccessfully.

While I was critical of over-engineering this, it turns out that
when we start to use `mut`, a macro is much more practical, because
it doesn't create a new scope where we need a copy of a mutable
reference, which of course is not allowed.

(cherry picked from commit a2acc93d13991da4b14a99065acd589477334d07)
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
c16a9b0595 refact: Make require_attrs_select* error handling regular
(cherry picked from commit de6c6cbd462202405bc787fed02dee249cf16973)
2025-10-04 02:31:16 +02:00
Robert Hensing
61efb9b79f refact: Add Context::check_one_call(f)
This makes it easier to stick to a regular pattern and not forget
to check the context afterwards.

(cherry picked from commit 966ef3769a23075f5d660a48cf5a7307df925dbf)
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
d38cf51c63 feat: Context.is_key_error
(cherry picked from commit f754e243852103164dbc6fdaf8c0cccb3c85cfb1)
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
Robert Hensing
acb1274c08 refact: Add callback_get_vec_u8_data
Make it easier to correctly use the string callbacks.

(cherry picked from commit 32db5dfc020053c36b7a4776313ee72d7bc961dd)
2025-10-04 02:30:46 +02:00
Taeer Bar-Yam
48af0f9e41 error checking tweaks
(cherry picked from commit 6ac38519b710e69a0c30eb0fe8fc5fa712168cb8)
2025-10-04 02:30:46 +02:00
Taeer Bar-Yam
c2159c8834 bindgen strip nix_ prefix
(cherry picked from commit d07ec1990015f5d12b39da40ad0cb1ef0e798642)
2025-10-04 02:30:46 +02:00
Robert Hensing
759577526d maint: Update get_uri to be callback based
(cherry picked from commit 1aaf9b4d764da5aa8c1297d87ad1002bf1d7a7ea)
2025-10-04 02:30:46 +02:00
Robert Hensing
7ef434a6d7 feat: Add nix-util crate with Context wrapper
(cherry picked from commit 6c8e116e8bbaecce2b77fd9e0db89f366b57f9b6)
2025-09-30 18:40:07 +02:00