forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
bazel_8: init at 8.4.0 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!@runtimeShell@ | ||
|
|
||
| exec @binJava@ -jar @out@/share/parser_deploy.jar "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| { | ||
| stdenv, | ||
| lndir, | ||
| lib, | ||
| }: | ||
|
|
||
| args@{ | ||
| bazel, | ||
| registry ? null, | ||
| bazelRepoCache ? null, | ||
| bazelVendorDeps ? null, | ||
| startupArgs ? [ ], | ||
| commandArgs ? [ ], | ||
| bazelPreBuild ? "", | ||
| bazelPostBuild ? "", | ||
| serverJavabase ? null, | ||
| targets, | ||
| command, | ||
| ... | ||
| }: | ||
|
|
||
| stdenv.mkDerivation ( | ||
| { | ||
| preBuildPhases = [ "preBuildPhase" ]; | ||
| preBuildPhase = | ||
| (lib.optionalString (bazelRepoCache != null) '' | ||
| # repo_cache needs to be writeable even in air-gapped builds | ||
| mkdir repo_cache | ||
| ${lndir}/bin/lndir -silent ${bazelRepoCache}/repo_cache repo_cache | ||
| '') | ||
|
|
||
| + (lib.optionalString (bazelVendorDeps != null) '' | ||
| mkdir vendor_dir | ||
| ${lndir}/bin/lndir -silent ${bazelVendorDeps}/vendor_dir vendor_dir | ||
|
|
||
| # pin all deps to avoid re-fetch attempts by Bazel | ||
| rm vendor_dir/VENDOR.bazel | ||
| find vendor_dir -mindepth 1 -maxdepth 1 -type d -printf "pin(\"@@%P\")\n" > vendor_dir/VENDOR.bazel | ||
| '') | ||
| # keep preBuildPhase always defined as it is listed in preBuildPhases | ||
| + '' | ||
| true | ||
| ''; | ||
| buildPhase = '' | ||
| runHook preBuild | ||
|
|
||
| export HOME=$(mktemp -d) | ||
|
|
||
| ${bazelPreBuild} | ||
|
|
||
| ${bazel}/bin/bazel ${ | ||
| lib.escapeShellArgs ( | ||
| lib.optional (serverJavabase != null) "--server_javabase=${serverJavabase}" | ||
| ++ [ "--batch" ] | ||
| ++ startupArgs | ||
| ) | ||
| } ${command} ${ | ||
| lib.escapeShellArgs ( | ||
| lib.optional (registry != null) "--registry=file://${registry}" | ||
| ++ lib.optional (bazelRepoCache != null) "--repository_cache=repo_cache" | ||
| ++ lib.optional (bazelVendorDeps != null) "--vendor_dir=vendor_dir" | ||
| ++ commandArgs | ||
| ++ targets | ||
| ) | ||
| } | ||
|
|
||
| ${bazelPostBuild} | ||
|
|
||
| runHook postBuild | ||
| ''; | ||
|
|
||
| } | ||
| // args | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| { | ||
| callPackage, | ||
| gnugrep, | ||
| lib, | ||
| autoPatchelfHook, | ||
| stdenv, | ||
| }: | ||
|
|
||
| { | ||
| name, | ||
| src, | ||
| sourceRoot ? null, | ||
| version ? null, | ||
| targets, | ||
| bazel, | ||
| startupArgs ? [ ], | ||
| commandArgs ? [ ], | ||
| env ? { }, | ||
| serverJavabase ? null, | ||
| registry ? null, | ||
| bazelRepoCacheFOD ? { | ||
| outputHash = null; | ||
| outputHashAlgo = "sha256"; | ||
| }, | ||
| bazelVendorDepsFOD ? { | ||
| outputHash = null; | ||
| outputHashAlgo = "sha256"; | ||
| }, | ||
| installPhase, | ||
| buildInputs ? [ ], | ||
| nativeBuildInputs ? [ ], | ||
| autoPatchelfIgnoreMissingDeps ? null, | ||
| }: | ||
| let | ||
| # FOD produced by `bazel fetch` | ||
| # Repo cache contains content-addressed external Bazel dependencies without any patching | ||
| # Potentially this can be nixified via --experimental_repository_resolved_file | ||
| # (Note: file itself isn't reproducible because it has lots of extra info and order | ||
| # isn't stable too. Parsing it into nix fetch* commands isn't trivial but might be possible) | ||
| bazelRepoCache = | ||
| if bazelRepoCacheFOD.outputHash == null then | ||
| null | ||
| else | ||
| (callPackage ./bazelDerivation.nix { } { | ||
| name = "bazelRepoCache"; | ||
| inherit (bazelRepoCacheFOD) outputHash outputHashAlgo; | ||
| inherit | ||
| src | ||
| version | ||
| sourceRoot | ||
| env | ||
| buildInputs | ||
| nativeBuildInputs | ||
| ; | ||
| inherit registry; | ||
| inherit | ||
| bazel | ||
| targets | ||
| startupArgs | ||
| serverJavabase | ||
| ; | ||
| command = "fetch"; | ||
| outputHashMode = "recursive"; | ||
| commandArgs = [ "--repository_cache=repo_cache" ] ++ commandArgs; | ||
| bazelPreBuild = '' | ||
| mkdir repo_cache | ||
| ''; | ||
| installPhase = '' | ||
| mkdir -p $out/repo_cache | ||
| cp -r --reflink=auto repo_cache/* $out/repo_cache | ||
| ''; | ||
| }); | ||
| # Stage1: FOD produced by `bazel vendor`, Stage2: eventual patchelf or other tuning | ||
| # Vendor deps contains unpacked&patches external dependencies, this may need Nix-specific | ||
| # patching to address things like | ||
| # - broken symlinks | ||
| # - symlinks or other references to absolute nix store paths which isn't allowed for FOD | ||
| # - autoPatchelf for externally-fetched binaries | ||
| # | ||
| # Either repo cache or vendor deps should be enough to build a given package | ||
| bazelVendorDeps = | ||
| if bazelVendorDepsFOD.outputHash == null then | ||
| null | ||
| else | ||
| ( | ||
| let | ||
| stage1 = callPackage ./bazelDerivation.nix { } { | ||
| name = "bazelVendorDepsStage1"; | ||
| inherit (bazelVendorDepsFOD) outputHash outputHashAlgo; | ||
| inherit | ||
| src | ||
| version | ||
| sourceRoot | ||
| env | ||
| buildInputs | ||
| nativeBuildInputs | ||
| ; | ||
| inherit registry; | ||
| inherit | ||
| bazel | ||
| targets | ||
| startupArgs | ||
| serverJavabase | ||
| ; | ||
| dontFixup = true; | ||
| command = "vendor"; | ||
| outputHashMode = "recursive"; | ||
| commandArgs = [ "--vendor_dir=vendor_dir" ] ++ commandArgs; | ||
| bazelPreBuild = '' | ||
| mkdir vendor_dir | ||
| ''; | ||
| bazelPostBuild = '' | ||
| # remove symlinks that point to locations under bazel_src/ | ||
| find vendor_dir -type l -lname "$HOME/*" -exec rm '{}' \; | ||
| # remove symlinks to temp build directory on darwin | ||
| find vendor_dir -type l -lname "/private/var/tmp/*" -exec rm '{}' \; | ||
| # remove broken symlinks | ||
| find vendor_dir -xtype l -exec rm '{}' \; | ||
|
|
||
| # remove .marker files referencing NIX_STORE as those references aren't allowed in FOD | ||
| (${gnugrep}/bin/grep -rI "$NIX_STORE/" vendor_dir --files-with-matches --include="*.marker" --null || true) \ | ||
| | xargs -0 --no-run-if-empty rm | ||
| ''; | ||
| installPhase = '' | ||
| mkdir -p $out/vendor_dir | ||
| cp -r --reflink=auto vendor_dir/* $out/vendor_dir | ||
| ''; | ||
|
|
||
| }; | ||
| in | ||
| stdenv.mkDerivation { | ||
| name = "bazelVendorDeps"; | ||
| buildInputs = lib.optional (!stdenv.hostPlatform.isDarwin) autoPatchelfHook ++ buildInputs; | ||
| inherit autoPatchelfIgnoreMissingDeps; | ||
| src = stage1; | ||
| installPhase = '' | ||
| cp -r . $out | ||
| ''; | ||
| } | ||
| ); | ||
|
|
||
| package = callPackage ./bazelDerivation.nix { } { | ||
| inherit | ||
| name | ||
| src | ||
| version | ||
| sourceRoot | ||
| env | ||
| buildInputs | ||
| nativeBuildInputs | ||
| ; | ||
| inherit registry bazelRepoCache bazelVendorDeps; | ||
| inherit | ||
| bazel | ||
| targets | ||
| startupArgs | ||
| serverJavabase | ||
| commandArgs | ||
| ; | ||
| inherit installPhase; | ||
| command = "build"; | ||
| }; | ||
| in | ||
| package // { passthru = { inherit bazelRepoCache bazelVendorDeps; }; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| stdenv, | ||
| }: | ||
| { | ||
| # If there's a need to patch external dependencies managed by Bazel | ||
| # one option is to configure patches on Bazel level. Bazel doesn't | ||
| # allow patches to be in absolute paths so this helper will produce | ||
| # sources patch that adds given file to given location | ||
| addFilePatch = | ||
| { | ||
| path, | ||
| file, | ||
| }: | ||
| stdenv.mkDerivation { | ||
| name = "add_file.patch"; | ||
| dontUnpack = true; | ||
| buildPhase = '' | ||
| mkdir -p $(dirname "${path}") | ||
| cp ${file} "${path}" | ||
| diff -u /dev/null "${path}" >result.patch || true # diff exit code is non-zero if there's a diff | ||
| ''; | ||
| installPhase = ''cp result.patch $out''; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| lib, | ||
| makeBinaryWrapper, | ||
| writeShellApplication, | ||
| bash, | ||
| stdenv, | ||
| }: | ||
| { defaultShellUtils }: | ||
| let | ||
| defaultShellPath = lib.makeBinPath defaultShellUtils; | ||
|
|
||
| bashWithDefaultShellUtilsSh = writeShellApplication { | ||
| name = "bash"; | ||
| runtimeInputs = defaultShellUtils; | ||
| # Empty PATH in Nixpkgs Bash is translated to /no-such-path | ||
| # On other distros empty PATH search fallback is looking in standard | ||
| # locations like /bin,/usr/bin | ||
| # For Bazel many rules rely on such search finding some common utils, | ||
| # so we provide them in case rules or arguments didn't specify a precise PATH | ||
| text = '' | ||
| if [[ "$PATH" == "/no-such-path" ]]; then | ||
| export PATH=${defaultShellPath} | ||
| fi | ||
| exec ${bash}/bin/bash "$@" | ||
| ''; | ||
| }; | ||
|
|
||
| in | ||
| { | ||
| inherit defaultShellUtils defaultShellPath; | ||
| # Script-based interpreters in shebangs aren't guaranteed to work, | ||
| # especially on MacOS. So let's produce a binary | ||
| bashWithDefaultShellUtils = stdenv.mkDerivation { | ||
| name = "bash"; | ||
| src = bashWithDefaultShellUtilsSh; | ||
| nativeBuildInputs = [ makeBinaryWrapper ]; | ||
| buildPhase = '' | ||
| makeWrapper ${bashWithDefaultShellUtilsSh}/bin/bash $out/bin/bash | ||
| ''; | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.