From 3782bfa7bfb9f42207484aa3d684152f6654d7e3 Mon Sep 17 00:00:00 2001 From: Nicolas Guichard Date: Mon, 20 Apr 2026 15:16:27 +0200 Subject: [PATCH 1/2] buildBazelPackage: support `__structuredAttrs = true` When using structured attributes, `bazelFlags` is an array. `$bazelFlags` then only returns the array's first item. Instead we need to use `"${bazelFlags[@]}"` which correctly returns all array items with proper support for spaces in individual flags. To remain compatible with the non-structured case, this adds a conversion from array or string `bazelFlags` into an array `bazelFlagsArray`. --- .../build-bazel-package/default.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index c6723a5a0d50..f4eabda2dc2f 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -86,6 +86,8 @@ let targetRunFlags ? [ ], }: lib.optionalString (targets != [ ]) '' + concatTo bazelFlagsArray bazelFlags + # See footnote called [USER and BAZEL_USE_CPP_ONLY_TOOLCHAIN variables] BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \ USER=homeless-shelter \ @@ -99,7 +101,7 @@ let "''${host_copts[@]}" \ "''${linkopts[@]}" \ "''${host_linkopts[@]}" \ - $bazelFlags \ + "''${bazelFlagsArray[@]}" \ ${lib.strings.concatStringsSep " " additionalFlags} \ ${lib.strings.concatStringsSep " " targets} \ ${ @@ -239,13 +241,24 @@ stdenv.mkDerivation ( ); dontFixup = true; - allowedRequisites = [ ]; inherit (lib.fetchers.normalizeHash { hashTypes = [ "sha256" ]; } fetchAttrs) outputHash outputHashAlgo ; } + // ( + if fFetchAttrs.__structuredAttrs or false then + { + # With __structuredAttrs = true, the build always fails with “output $out is not allowed to refer to the following paths: $out”. + # This appears to be the same issue as in 283bca9648fc1afb01d3e4c3b5919251429da907. + outputChecks.out.allowedRequisites = [ "out" ]; + } + else + { + allowedRequisites = [ ]; + } + ) ); nativeBuildInputs = fBuildAttrs.nativeBuildInputs or [ ] ++ [ From aa65cbf68e645cae38f8e58da54cc47f6e5c6fa5 Mon Sep 17 00:00:00 2001 From: Nicolas Guichard Date: Tue, 21 Apr 2026 23:00:44 +0200 Subject: [PATCH 2/2] bant: set __structuredAttrs and strictDeps --- pkgs/by-name/ba/bant/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/ba/bant/package.nix b/pkgs/by-name/ba/bant/package.nix index 634e2ccd5aba..9860fe294a7e 100644 --- a/pkgs/by-name/ba/bant/package.nix +++ b/pkgs/by-name/ba/bant/package.nix @@ -73,6 +73,9 @@ buildBazelPackage rec { passthru.updateScript = nix-update-script { }; + strictDeps = true; + __structuredAttrs = true; + meta = { description = "Bazel/Build Analysis and Navigation Tool"; homepage = "http://bant.build/";