diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index 058f42aa8d5a..47c72bf92602 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -122,6 +122,8 @@ in stdenv.mkDerivation (fBuildAttrs // { cp -r $bazelOut/external $out + echo '${bazel.name}' > $out/.nix-bazel-version + runHook postInstall ''; @@ -143,6 +145,14 @@ in stdenv.mkDerivation (fBuildAttrs // { preConfigure = '' mkdir -p "$bazelOut" + + test "${bazel.name}" = "$(<$deps/.nix-bazel-version)" || { + echo "fixed output derivation was built for a different bazel version" >&2 + echo " got: $(<$deps/.nix-bazel-version)" >&2 + echo "expected: ${bazel.name}" >&2 + exit 1 + } + cp -r $deps $bazelOut/external chmod -R +w $bazelOut find $bazelOut -type l | while read symlink; do