Commit graph

88 commits

Author SHA1 Message Date
Robert Hensing
65c9d937cd nix-expr: Improve docs
... and fix an error message

(cherry picked from commit ec3b5cfb911545ecf756336e792b59c5dd1be9b5)
2025-10-04 02:31:17 +02:00
Robert Hensing
41c99e02cf feat: nix_expr::eval_state::require_list_strict
(cherry picked from commit 647854fd767b156c3a5db2da0e5659e040a69534)
2025-10-04 02:31:17 +02:00
Robert Hensing
759550b47f refact: Rename require_list_select_idx -> require_list_select_idx_strict + tests
The rename makes it so that we'll have the original name for the more
sensible lazy behavior.

(cherry picked from commit 6fdae53df54da0c6349ac32789ec67e3a25a5774)
2025-10-04 02:31:17 +02:00
Tristan Ross
4e80e1ad4a feat: nix_expr::eval_state::require_list functions
(cherry picked from commit 8498ebe3dddb34b274d83895b9bfecfb36ef6ab7)
2025-10-04 02:31:17 +02:00
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
b3a80dd36e maint: Remove Cargo.toml patch constraints
(cherry picked from commit 155550be6a8487771ddb67d09f3eba829e54e622)
2025-10-04 02:31:16 +02:00
Robert Hensing
e6b993a42b feat: nix_expr::value::__private
Exposes the Value constructors, for use by other bindings like
nix-flake, which needs to construct e.g. a flake outputs Value.

See https://github.com/nixops4/nixops4/issues/25

> We have two related issues:

> A bunch of implementation details cannot be made private, since they must be used from one of the other crates (e.g. Values are defined in the value module but used from eval_state
> While we don't want users to need to use these features, it may be good to provide escape hatches so they can interface with the raw API if they need more control.
> Problem (1) has been solved in other crates with a __private module with #[doc(hidden)] set. See for instance:

I'm leaving docs turned on for (2). The issue has more thoughts about
alternatives.

(cherry picked from commit eb6744d1519febe5b6aa6233eb3f3e8a049f12d4)
2025-10-04 02:31:16 +02:00
Robert Hensing
3b7a14f62b feat: EvalState.require_bool
(cherry picked from commit e0d451f22cedae383fa2f18809f3494e674371b4)
2025-10-04 02:31:16 +02:00
Robert Hensing
8f7d3d5385 maint: Add EvalStateBuilder.flakes(settings)
(cherry picked from commit ee55ef51a60abc692fdef69614c9a8ccfa9358e0)
2025-10-04 02:31:16 +02:00
Robert Hensing
2cab738e58 feat: EvalStateBuilder
This supports the more "advanced" `nix_eval_state_builder`, which
has more methods that we'll want to use.

(cherry picked from commit a96047000df6b7022d166a8c35bb6e3075e5eddb)
2025-10-04 02:31:16 +02:00
Robert Hensing
2508facd82 feat: Improve EvalState::require_attrs_select error message
(cherry picked from commit 220b6f4123966d818064f4114477ce8676214b90)
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
cbce27eb64 feat: Support Store::open from environment, not just auto
Note that `"auto"` holds a strange middle ground, reading
part of the general environment, but not all of it. It
ignores `NIX_REMOTE` and the `store` option.

(cherry picked from commit 7ba92a3793c2fe11938e802e6b61edee042b193a)
2025-10-04 02:31:16 +02:00
Robert Hensing
122ee75ce3 fix: Darwin compat
(cherry picked from commit 711d95877a039bcd5b162604a22d1c051b59a49d)
2025-10-04 02:31:16 +02:00
Robert Hensing
d19dd45bbf fix: Mark all pointer manipulation as unsafe
See b43455fdd0468f067741a79a7031ba2fa907f0eb for rationale

(cherry picked from commit b9996c6ddd3973cd419930210bf11a4d1bc6350b)
2025-10-04 02:31:16 +02:00
Robert Hensing
6193575d1e fix: Require non-null pointer in StorePath
Fixes https://github.com/nixops4/nixops4/issues/65,
possible undefined behavior.

This doesn't make the code nice wrt *const/*mut distinction, but
since we're not mutating it, this should be fine.

(cherry picked from commit 75d448aad923a5f835f0562400e223df43103ea4)
2025-10-04 02:31:16 +02:00
Robert Hensing
28deb20a2b feat: EvalState.new_value_attrs
(cherry picked from commit 5b3f4d97f968b518c901c2de3759640b91fd37c2)
2025-10-04 02:31:16 +02:00
Robert Hensing
dc01d3731f feat: Add EvalState::call_multi
(cherry picked from commit e1866f0c61011ffb57b607abe871340aca294f19)
2025-10-04 02:31:16 +02:00
Robert Hensing
8a437b71a0 test: Fix flaky eval_state_value_attrs_names_example
(cherry picked from commit 4583b422038661de02c6fe672559d2519f38dfce)
2025-10-04 02:31:16 +02:00
Robert Hensing
76b92a577d feat: Add EvalState.require_attrs_names (sorted)
(cherry picked from commit 0b1aca5a1ee7136e76a201477643cfc3acbf2676)
2025-10-04 02:31:16 +02:00
Robert Hensing
237a2281c1 refact: require_attrs_names -> require_attrs_names_unsorted
(cherry picked from commit 13a3adf4f17351bc6ba3d91567a642ec1ae704f6)
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
12d3d62108 fix: Deduplicate stores to work around nix#11979
Fixes tests hanging. Before this commit:

    nix build .#packages.x86_64-linux.nixops4-eval-release

See https://github.com/NixOS/nix/issues/11979

(cherry picked from commit 03af71f92488f2ee683565318f24afd3e3c001df)
2025-10-04 02:31:16 +02:00
Robert Hensing
1c0e2cd72f maint: Unset substituters in nix-expr tests
Runs offline, and would only slow things down.

(cherry picked from commit ea3ef1c59a1fe8e380302acc1885877a1ac8e0b6)
2025-10-04 02:31:16 +02:00
Robert Hensing
77c9be2cbf maint: Fix nix-expr tests by unsetting build hook
(cherry picked from commit 52b6cd6b7867dafe0906184e540c5195ba776ae9)
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
4eade817b6 refact: Remove gc_registering_current_thread
Closes #31

A guard object is more capable, as it can be used in various
control flow and ownership schemes, including async code, but not
that it is not Send.

(cherry picked from commit f9aa5eab2561834c64ef9fe01979a91aee35848f)
2025-10-04 02:31:16 +02:00
Robert Hensing
ad0f5d0240 fix: Remove impl Send for Value for now
They're somewhat safe to use on a different thread, but we don't need
to for now. By removing this, we'll be made aware as needed.

(cherry picked from commit 2e953d0a1268e2f19671fdbc9e721fc630ac346b)
2025-10-04 02:31:16 +02:00
Robert Hensing
f177507f88 feat: Add ThreadRegistrationGuard in nix-expr
(cherry picked from commit f287122e354535c2ee2f16c930038b19142f522a)
2025-10-04 02:31:16 +02:00
Robert Hensing
b714f46e07 feat: Make nixops4-eval async
A step toward handling the arrival of new data (stdin) with priority
over commands, avoiding roundtrips and re-evaluations.

(cherry picked from commit 8a2a5197886025caf35653001f76a4b209d8c9e4)
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
5355b663c0 refact: Inline new_value_function(), a test helper
(cherry picked from commit a354accb952558d30a780eb57fd3161be139db7d)
2025-10-04 02:31:16 +02:00
Robert Hensing
b5f9764c4c refact: Remove some lazy_static test globals
(cherry picked from commit 4f0ce4960ec468679993cc9fd70820f6d0532c09)
2025-10-04 02:31:16 +02:00
Robert Hensing
ee6c04a941 feat: Reintroduce EvalState::new_value_thunk
(cherry picked from commit a2c49a524cf76ca2c9a6759d271d58076756ac09)
2025-10-04 02:31:16 +02:00
Robert Hensing
da9bb4c885 cleanup: Remove EvalState::new_value_function
It provides not so great values for some of the parameters, and we
don't really need its convenience.

(cherry picked from commit 52b7b58eb7fa96a265883cbf92e3a635735fe360)
2025-10-04 02:31:16 +02:00
Robert Hensing
312c86b811 feat: PrimOp type
(cherry picked from commit 67616c4a55b9d98d716384ffc07d3b3880dd76e4)
2025-10-04 02:31:16 +02:00
Robert Hensing
5c43a28cf0 Basic primops support
(cherry picked from commit e1be238ad440ad6f73a4f15cb752439b240a0333)
2025-10-04 02:31:16 +02:00
Robert Hensing
01c9d0b2d3 feat: EvalState.weak_ref()
(cherry picked from commit d7a72c82ebfbfbb1b58fa15044b63648b2109260)
2025-10-04 02:31:16 +02:00
Robert Hensing
3d5c64c4a6 feat: impl Clone for EvalState
(cherry picked from commit f22d9ba23564107480f627a5901a52f044034c98)
2025-10-04 02:31:16 +02:00
Robert Hensing
9cebf1d131 feat: Value::new_borrowed
(cherry picked from commit 86e3828250d4de15f9cf49d19222eb382c77f7e2)
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
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