From 921e7aee81e6f25cf4e6f98044a9c3dd91543fe3 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 16 May 2020 16:37:42 +0100 Subject: [PATCH] third_party/nixpkgs: buildBazelPackage: add "fetchConfigured", and allow removing things that sometimes don't exist --- .../build-support/build-bazel-package/default.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/third_party/nixpkgs/pkgs/build-support/build-bazel-package/default.nix b/third_party/nixpkgs/pkgs/build-support/build-bazel-package/default.nix index 9a64b84f07..a1e7ae8ff8 100644 --- a/third_party/nixpkgs/pkgs/build-support/build-bazel-package/default.nix +++ b/third_party/nixpkgs/pkgs/build-support/build-bazel-package/default.nix @@ -30,6 +30,13 @@ args@{ , removeRulesCC ? true , removeLocalConfigCc ? true , removeLocal ? true + +# Use build --nobuild instead of fetch. This allows fetching the dependencies +# required for the build as configured, rather than fetching all the dependencies +# which may not work in some situations (e.g. Java code which ends up relying on +# Debian-specific /usr/share/java paths, but doesn't in the configured build). +, fetchConfigured ? true + , ... }: @@ -77,7 +84,7 @@ in stdenv.mkDerivation (fBuildAttrs // { bazel \ --output_base="$bazelOut" \ --output_user_root="$bazelUserRoot" \ - fetch \ + ${if fetchConfigured then "build --nobuild" else "fetch"} \ --loading_phase_threads=1 \ $bazelFlags \ $bazelFetchFlags \ @@ -110,7 +117,7 @@ in stdenv.mkDerivation (fBuildAttrs // { # platforms -> NIX_BUILD_TOP/tmp/install/35282f5123611afa742331368e9ae529/_embedded_binaries/platforms find $bazelOut/external -maxdepth 1 -type l | while read symlink; do name="$(basename "$symlink")" - rm "$symlink" "$bazelOut/external/@$name.marker" + rm -f "$symlink" "$bazelOut/external/@$name.marker" done # Patching symlinks to remove build directory reference