Commit graph

60 commits

Author SHA1 Message Date
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
Robert Hensing
93a2db836a doc: Clarify why we test call and apply and how they relate
(cherry picked from commit 17c7a8d30d1c4d99eeb84a6203ae33d2ba781edb)
2025-10-04 02:31:16 +02:00
Robert Hensing
b04d429f19 test: Make sure require_* functions force thunks
(cherry picked from commit 69b661db22e4b16fb08d322f5fede480438e2b71)
2025-10-04 02:31:16 +02:00
Robert Hensing
878b793161 test: eval_state_require_int_forces_thunk
(cherry picked from commit 90de70936a726a8ae1aaf3e9aacb9a83b8d30b72)
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
c775792b63 fix: Do not unwrap() in require_int
(cherry picked from commit c7d2e3e02a977424634ee12015265906e18039a0)
2025-10-04 02:31:16 +02:00
Robert Hensing
22ffd20c53 refact: Use Option instead of custom ValueTypeOrThunk
This loses the custom name for "thunk", but checking thunkness is
a niche use case that I don't think we should spend much code on.

(cherry picked from commit 7bdff525c13234ce6a32ea9346292d948b0840c1)
2025-10-04 02:31:16 +02:00
Philipp
19361acb12 rename value_type_forced to value_type
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
(cherry picked from commit 3bf206a38e20109bbee9cd781e66bcd895ed95ce)
2025-10-04 02:31:16 +02:00
Philipp Zander
627b31d6c5 refact: adjust ValueType use sites
(cherry picked from commit 9d9f7d59c6df3db26f331e63c9b210f8fae19061)
2025-10-04 02:31:16 +02:00
Philipp Zander
673f80e243 refact: remove Thunk from ValueType and introduce ValueTypeOrThunk to address #30
(cherry picked from commit 97c05175b633b364686790549b11e43cfb2f1d2c)
2025-10-04 02:31:16 +02:00
Philipp Zander
d89fb1803f doc: EvalState::eval_from_string
(cherry picked from commit b1de918abddc8166973c956ec77d597dae92f928)
2025-10-04 02:31:16 +02:00
Philipp Zander
fe4d62d083 test nix_store_open's params argument
(cherry picked from commit 2cebb64daacdc612e7ff916dc32b0fe5ed89dbfc)
2025-10-04 02:31:16 +02:00
Philipp Zander
ec28176852 adjust all tests to nix_store_open's new signature
(cherry picked from commit da9bf071709bc9e48a0a02531e78b2a71a9b4eba)
2025-10-04 02:31:16 +02:00
Robert Hensing
37da6411d0 maint: Use /// for doc comments
(cherry picked from commit 4a390197f71653dda99696ed5c9cbca8c6a95a4b)
2025-10-04 02:31:16 +02:00
Philipp Zander
ffdbf49ec5 test: Add assertion in eval_state::tests::eval_state_apply
(cherry picked from commit f8ff14274b6f7accf987328928186b25f842071f)
2025-10-04 02:31:16 +02:00
Robert Hensing
78435d4ed7 feat: EvalState::new_value_apply
(cherry picked from commit f8143ae4ed7b62b86cb232f8d73e53bae30d632c)
2025-10-04 02:31:16 +02:00
Philipp Zander
9a62664fb1 test nix_state_create's lookupPath argument
(cherry picked from commit 6e5a259f60725b632e52d4839e6e3c285d6971d4)
2025-10-04 02:30:46 +02:00
Philipp Zander
d817e86c59 feat: support nix_state_create's lookupPath argument
(cherry picked from commit 6d0906688ea40760217c2e017a4a0a61eb0fd611)
2025-10-04 02:30:46 +02:00
Robert Hensing
726e891be8 feat: eval_state::test_init
(cherry picked from commit 040982222c9eb8ea91d7174e6f2e21bbc6cda8a4)
2025-10-04 02:30:46 +02:00
Robert Hensing
4095bda02a feat: EvalState.require_attrs_select{,_opt}
(cherry picked from commit cbba454aba1a90bb862d49925edd13820b6ace1b)
2025-10-04 02:30:46 +02:00
Robert Hensing
49576f82e4 feat: EvalState.require_attrs_names
(cherry picked from commit 1f9fdcb3805ecf74e3c0451c11bdfae96f6f997b)
2025-10-04 02:30:46 +02:00
Robert Hensing
024ef333cb feat: EvalState.new_value_int
(cherry picked from commit aa79e4d0db7795ab059349e6f6bc764d17afe003)
2025-10-04 02:30:46 +02:00
Robert Hensing
cd5fa278eb feat: EvalState.new_value_str
(cherry picked from commit 94830e4c23ddc742eb7a70cb3e0c4cf17a1a0231)
2025-10-04 02:30:46 +02:00
Robert Hensing
52778c37e9 feat: EvalState.call
(cherry picked from commit f3aa6e523c0c5214533d0005d8c3f85a0579b1de)
2025-10-04 02:30:46 +02:00
Robert Hensing
fbbc7cb490 feat: EvalState.require_int
(cherry picked from commit 890441adf963f1a33ba75889cc9735deeefbf51c)
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
a2686c31b2 refact: Distribute unwrap()
This gives us better error messages in case it does go wrong.

(cherry picked from commit 0fec573d82b6c51e72183ae5a19c922a53863d5b)
2025-10-04 02:30:46 +02:00
Robert Hensing
625d17b0db doc: Explain why we might need to clear the build hook
(cherry picked from commit 52d81586c671226ab2c1bbe0e1914c11b58239da)
2025-10-04 02:30:46 +02:00