@@ -265,17 +265,47 @@ ExternalValue * nix_get_external(nix_c_context * context, nix_value * value);
265265 */
266266nix_value * nix_get_list_byidx (nix_c_context * context , const nix_value * value , EvalState * state , unsigned int ix );
267267
268- /** @brief Get an attr by name
268+ /** @brief Get the ix'th element of a list without forcing evaluation of the element
269+ *
270+ * Returns the list element without forcing its evaluation, allowing access to lazy values.
271+ * The list value itself must already be evaluated.
269272 *
270273 * Owned by the GC. Use nix_gc_decref when you're done with the pointer
271274 * @param[out] context Optional, stores error information
275+ * @param[in] value Nix value to inspect (must be an evaluated list)
276+ * @param[in] state nix evaluator state
277+ * @param[in] ix list element to get
278+ * @return value, NULL in case of errors
279+ */
280+ nix_value *
281+ nix_get_list_byidx_lazy (nix_c_context * context , const nix_value * value , EvalState * state , unsigned int ix );
282+
283+ /** @brief Get an attr by name
284+ *
285+ * Use nix_gc_decref when you're done with the pointer
286+ * @param[out] context Optional, stores error information
272287 * @param[in] value Nix value to inspect
273288 * @param[in] state nix evaluator state
274289 * @param[in] name attribute name
275290 * @return value, NULL in case of errors
276291 */
277292nix_value * nix_get_attr_byname (nix_c_context * context , const nix_value * value , EvalState * state , const char * name );
278293
294+ /** @brief Get an attribute value by attribute name, without forcing evaluation of the attribute's value
295+ *
296+ * Returns the attribute value without forcing its evaluation, allowing access to lazy values.
297+ * The attribute set value itself must already be evaluated.
298+ *
299+ * Use nix_gc_decref when you're done with the pointer
300+ * @param[out] context Optional, stores error information
301+ * @param[in] value Nix value to inspect (must be an evaluated attribute set)
302+ * @param[in] state nix evaluator state
303+ * @param[in] name attribute name
304+ * @return value, NULL in case of errors
305+ */
306+ nix_value *
307+ nix_get_attr_byname_lazy (nix_c_context * context , const nix_value * value , EvalState * state , const char * name );
308+
279309/** @brief Check if an attribute name exists on a value
280310 * @param[out] context Optional, stores error information
281311 * @param[in] value Nix value to inspect
@@ -285,11 +315,21 @@ nix_value * nix_get_attr_byname(nix_c_context * context, const nix_value * value
285315 */
286316bool nix_has_attr_byname (nix_c_context * context , const nix_value * value , EvalState * state , const char * name );
287317
288- /** @brief Get an attribute by index in the sorted bindings
318+ /** @brief Get an attribute by index
289319 *
290320 * Also gives you the name.
291321 *
292- * Owned by the GC. Use nix_gc_decref when you're done with the pointer
322+ * Attributes are returned in an unspecified order which is NOT suitable for
323+ * reproducible operations. In Nix's domain, reproducibility is paramount. The caller
324+ * is responsible for sorting the attributes or storing them in an ordered map to
325+ * ensure deterministic behavior in your application.
326+ *
327+ * @note When Nix does sort attributes, which it does for virtually all intermediate
328+ * operations and outputs, it uses byte-wise lexicographic order (equivalent to
329+ * lexicographic order by Unicode scalar value for valid UTF-8). We recommend
330+ * applying this same ordering for consistency.
331+ *
332+ * Use nix_gc_decref when you're done with the pointer
293333 * @param[out] context Optional, stores error information
294334 * @param[in] value Nix value to inspect
295335 * @param[in] state nix evaluator state
@@ -300,9 +340,47 @@ bool nix_has_attr_byname(nix_c_context * context, const nix_value * value, EvalS
300340nix_value *
301341nix_get_attr_byidx (nix_c_context * context , nix_value * value , EvalState * state , unsigned int i , const char * * name );
302342
303- /** @brief Get an attribute name by index in the sorted bindings
343+ /** @brief Get an attribute by index, without forcing evaluation of the attribute's value
344+ *
345+ * Also gives you the name.
346+ *
347+ * Returns the attribute value without forcing its evaluation, allowing access to lazy values.
348+ * The attribute set value itself must already have been evaluated.
349+ *
350+ * Attributes are returned in an unspecified order which is NOT suitable for
351+ * reproducible operations. In Nix's domain, reproducibility is paramount. The caller
352+ * is responsible for sorting the attributes or storing them in an ordered map to
353+ * ensure deterministic behavior in your application.
354+ *
355+ * @note When Nix does sort attributes, which it does for virtually all intermediate
356+ * operations and outputs, it uses byte-wise lexicographic order (equivalent to
357+ * lexicographic order by Unicode scalar value for valid UTF-8). We recommend
358+ * applying this same ordering for consistency.
359+ *
360+ * Use nix_gc_decref when you're done with the pointer
361+ * @param[out] context Optional, stores error information
362+ * @param[in] value Nix value to inspect (must be an evaluated attribute set)
363+ * @param[in] state nix evaluator state
364+ * @param[in] i attribute index
365+ * @param[out] name will store a pointer to the attribute name
366+ * @return value, NULL in case of errors
367+ */
368+ nix_value * nix_get_attr_byidx_lazy (
369+ nix_c_context * context , nix_value * value , EvalState * state , unsigned int i , const char * * name );
370+
371+ /** @brief Get an attribute name by index
372+ *
373+ * Returns the attribute name without forcing evaluation of the attribute's value.
374+ *
375+ * Attributes are returned in an unspecified order which is NOT suitable for
376+ * reproducible operations. In Nix's domain, reproducibility is paramount. The caller
377+ * is responsible for sorting the attributes or storing them in an ordered map to
378+ * ensure deterministic behavior in your application.
304379 *
305- * Useful when you want the name but want to avoid evaluation.
380+ * @note When Nix does sort attributes, which it does for virtually all intermediate
381+ * operations and outputs, it uses byte-wise lexicographic order (equivalent to
382+ * lexicographic order by Unicode scalar value for valid UTF-8). We recommend
383+ * applying this same ordering for consistency.
306384 *
307385 * Owned by the nix EvalState
308386 * @param[out] context Optional, stores error information
0 commit comments