From d4434809feef76c704e815634c9f1d256fbf4a96 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Sun, 7 Dec 2025 22:59:22 +0300 Subject: [PATCH 1/3] tests/nixos/fethers-substitute: Fix for nix path-info --json-format 2 --- tests/nixos/fetchers-substitute.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/nixos/fetchers-substitute.nix b/tests/nixos/fetchers-substitute.nix index dc3bb7c02..5363f8e72 100644 --- a/tests/nixos/fetchers-substitute.nix +++ b/tests/nixos/fetchers-substitute.nix @@ -47,6 +47,7 @@ { nodes }: # python '' import json + import os start_all() @@ -118,9 +119,8 @@ # Get the NAR hash of the unpacked tarball in SRI format path_info_json = substituter.succeed(f"nix path-info --json-format 2 --json {tarball_store_path}").strip() - path_info_dict = json.loads(path_info_json) - # nix path-info returns a dict with store paths as keys - narHash_obj = path_info_dict[tarball_store_path]["narHash"] + path_info_dict = json.loads(path_info_json)["info"] + narHash_obj = path_info_dict[os.path.basename(tarball_store_path)]["narHash"] # Convert from structured format {"algorithm": "sha256", "format": "base16", "hash": "..."} to SRI string tarball_hash_sri = substituter.succeed(f"nix hash convert --to sri {narHash_obj['algorithm']}:{narHash_obj['hash']}").strip() print(f"Tarball NAR hash (SRI): {tarball_hash_sri}") From 2f80fc473f1a71cce62cfeaed6f335fc52acd585 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Mon, 8 Dec 2025 00:24:46 +0300 Subject: [PATCH 2/3] libexpr-tests: Work around LTO issue with SAMPLE_USER_DATA on i686-linux with sanitizers This somehow fails https://hydra.nixos.org/build/315675349/nixlog/1. I don't know the exact details, but it seems that something goes very wrong with LTO and sanitizers that lead to the string literal to be moved? Instead of relying on the string literal deduplication to provide a consistent address we can use a global. That should have a single address (modulo wonky copy relocations). --- src/libexpr-tests/nix_api_expr.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libexpr-tests/nix_api_expr.cc b/src/libexpr-tests/nix_api_expr.cc index fdd09a449..c7e246c72 100644 --- a/src/libexpr-tests/nix_api_expr.cc +++ b/src/libexpr-tests/nix_api_expr.cc @@ -232,22 +232,22 @@ TEST_F(nix_api_expr_test, nix_expr_realise_context) nix_realised_string_free(r); } -const char * SAMPLE_USER_DATA = "whatever"; +static const char SAMPLE_USER_DATA = 0; static void primop_square(void * user_data, nix_c_context * context, EvalState * state, nix_value ** args, nix_value * ret) { assert(context); assert(state); - assert(user_data == SAMPLE_USER_DATA); + assert(user_data == &SAMPLE_USER_DATA); auto i = nix_get_int(context, args[0]); nix_init_int(context, ret, i * i); } TEST_F(nix_api_expr_test, nix_expr_primop) { - PrimOp * primop = - nix_alloc_primop(ctx, primop_square, 1, "square", nullptr, "square an integer", (void *) SAMPLE_USER_DATA); + PrimOp * primop = nix_alloc_primop( + ctx, primop_square, 1, "square", nullptr, "square an integer", const_cast(&SAMPLE_USER_DATA)); assert_ctx_ok(); nix_value * primopValue = nix_alloc_value(ctx, state); assert_ctx_ok(); @@ -273,7 +273,7 @@ primop_repeat(void * user_data, nix_c_context * context, EvalState * state, nix_ { assert(context); assert(state); - assert(user_data == SAMPLE_USER_DATA); + assert(user_data == &SAMPLE_USER_DATA); // Get the string to repeat std::string s; @@ -295,8 +295,8 @@ primop_repeat(void * user_data, nix_c_context * context, EvalState * state, nix_ TEST_F(nix_api_expr_test, nix_expr_primop_arity_2_multiple_calls) { - PrimOp * primop = - nix_alloc_primop(ctx, primop_repeat, 2, "repeat", nullptr, "repeat a string", (void *) SAMPLE_USER_DATA); + PrimOp * primop = nix_alloc_primop( + ctx, primop_repeat, 2, "repeat", nullptr, "repeat a string", const_cast(&SAMPLE_USER_DATA)); assert_ctx_ok(); nix_value * primopValue = nix_alloc_value(ctx, state); assert_ctx_ok(); @@ -330,8 +330,8 @@ TEST_F(nix_api_expr_test, nix_expr_primop_arity_2_multiple_calls) TEST_F(nix_api_expr_test, nix_expr_primop_arity_2_single_call) { - PrimOp * primop = - nix_alloc_primop(ctx, primop_repeat, 2, "repeat", nullptr, "repeat a string", (void *) SAMPLE_USER_DATA); + PrimOp * primop = nix_alloc_primop( + ctx, primop_repeat, 2, "repeat", nullptr, "repeat a string", const_cast(&SAMPLE_USER_DATA)); assert_ctx_ok(); nix_value * primopValue = nix_alloc_value(ctx, state); assert_ctx_ok(); From 0302cd00c9d558589fcc615393bbcf7f83a2e5d0 Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Mon, 8 Dec 2025 00:37:10 +0300 Subject: [PATCH 3/3] packaging/hydra: Don't build kaitai nar docs tests in hydra It's not evaling on hydra currently and is only part of the docs. Support for this it best effort at best so we should not build this in hydra, considering the amount of effort required to support this. I would even consider dropping these checks and component altogether, since there doesn't seem to be much interest in maintaining these docs from the core team anyway. --- packaging/hydra.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/hydra.nix b/packaging/hydra.nix index 20605418b..3a31314f7 100644 --- a/packaging/hydra.nix +++ b/packaging/hydra.nix @@ -63,7 +63,6 @@ let "nix-cli" "nix-functional-tests" "nix-json-schema-checks" - "nix-kaitai-struct-checks" ] ++ lib.optionals enableBindings [ "nix-perl-bindings" @@ -73,6 +72,7 @@ let "nix-manual-manpages-only" "nix-internal-api-docs" "nix-external-api-docs" + "nix-kaitai-struct-checks" ] ); in