Skip to content
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

bazel: take into account system wide bazelrc configuration if it exists #74976

Merged
merged 4 commits into from Dec 6, 2019

Conversation

@guibou
Copy link
Contributor

@guibou guibou commented Dec 4, 2019

Motivation for this change

closes #70911

This was extracted from #73309 to respect separation of concern.

Edit: after a few discussion with @flokli, this PR also refactors a bit of the bazelrc configuration handling:

  • the new bazelrc file is generated in its own nix store path. That's cleaner.
  • the replacement in the bazel source code is done using a patch, this way a regression will be catched earlier on.
  • the wrap of bazel was replaced by entries in the bazelrc file

cc @flokli

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @flokli

@guibou guibou requested a review from Profpatsch as a code owner Dec 4, 2019
@ofborg ofborg bot requested a review from mboes Dec 4, 2019
@flokli
Copy link
Contributor

@flokli flokli commented Dec 4, 2019

We currently abuse bazels /etc/bazel.bazelrc feature to "configure" nixpkgs bazel.

We patch bazel to read from $out/etc/bazelrc (causing #70911), and then append some config statements in there while building bazel.

We also use wrapProgram to append some options to the bazel binary directly: --server_javabase="${runJdk}".

I think we use $out/etc/bazelrc simply because some of the arguments would need to be passed to the binary depending on $argv[1], which requires a custom wrapper.

I think the cleanest way forward would probably be to simply patch the default locations hardcoded into the source code. Maybe there's even a way to configure those during runtime, I haven't really checked.

cc @aherrmann

@flokli
Copy link
Contributor

@flokli flokli commented Dec 4, 2019

Can this PR replace the wrapProgram "$out/bin/bazel" --add-flags --server_javabase="${runJdk}" with adding that flag to the bazelrc as well, so we at least only use one way to configure the nixpkgs-style bazel?

@guibou guibou force-pushed the guibou:bazel_config_file_system branch 2 times, most recently from 53ce09d to 274578b Dec 5, 2019
@guibou guibou force-pushed the guibou:bazel_config_file_system branch from 274578b to 15701d3 Dec 5, 2019
@flokli flokli self-requested a review Dec 5, 2019
guibou added 3 commits Dec 5, 2019
This way, custom configurations are all at the same place. Also, user
may override these settings using the command line.
Some system may setup global informations (such as bazel cache location)
in /etc/bazel.bazelrc
In bazel source code change in the future, patch will fail and we'll
detect the regression sooner.
@guibou guibou force-pushed the guibou:bazel_config_file_system branch from 15701d3 to 4fdea73 Dec 5, 2019
@flokli
Copy link
Contributor

@flokli flokli commented Dec 6, 2019

@GrahamcOfBorg build bazel bazel.tests

@flokli flokli merged commit 5233338 into NixOS:master Dec 6, 2019
17 of 18 checks passed
17 of 18 checks passed
bazel, bazel.tests on x86_64-linux
Details
Evaluation Performance Report Evaluator Performance Report
Details
bazel on aarch64-linux Success
Details
bazel on x86_64-linux Success
Details
bazel, bazel.tests on aarch64-linux Success
Details
bazel, bazel.tests on x86_64-darwin Success
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-maintainers matching changed paths to changed attrs...
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A darwin-tested
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release-combined.nix -A tested
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A manual
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./nixos/release.nix -A options
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A manual
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A tarball
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="ofborg"; } ./pkgs/top-level/release.nix -A unstable
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@guibou guibou deleted the guibou:bazel_config_file_system branch Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.