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: 0.12.0 -> 0.13.0 #40424
bazel: 0.12.0 -> 0.13.0 #40424
Conversation
Duplicate of #40205 |
Oh cool, that wasn't there when I started working on this, let me rebase it. |
Would be great if you and @rdnetto4 can merge your PRs into one. |
What was wrong with the |
It doesn't work when building |
Not using the Note this also means the projects being built with Bazel after the hack is removed will have to configure the build correctly using |
here's a simple fix for that:
I'm not sure I understand this one. Even in a pure shell, Bazel uses the grep, sed etc provided by
This is a big breaking change (all rules everywhere would have to be updated) that could make builds non-reproducible depending on whether the user uses Bazel through Nixpkgs or not. Why do you think this would be the "correct" thing to do? In https://github.com/tweag/rules_haskell, we try to avoid
This is a problem, though unrelated to the upgrade to 0.13 I guess, which can make do with the smaller change I outlined above. And there are other ways to work around this problem that potentially need less patching. Like creating a binary wrapper instead of script one. |
For reference, Bazel 0.13 builds projects successfully with the following commit: mboes@40c18d9. |
Yeah I'm not convinced it's the best way to go.
Good idea!
It's true that the Bazel build does use sed and other tools, so there might be something I'm missing for customBash to be able to find them, maybe stdenv.shell already includes all tools available to nix derivations? In which case why is coreutils specified explicitly?
Builds with Bazel are already non-reproducible if you switch the installation method: Bazel installed with Nix will use binaries from the Nix store, including java and gcc, and Bazel installed from other package managers will use binaries installed in the system, whichever they might be.
This lets you define the environment you're running Bazel in in your Bazel build definitions instead of relying on the environment specified in the Nix derivation: it would be quite strange if you had access to some tools but not others. For example assuming I understand
Yeah The big difference between the wrapper and absolute paths approaches is the environment Bazel runs actions in by default:
Note that in the first case the actions should use binaries from nix, so assuming you pinned the nixpkgs commit, you should get reproducible builds. |
From what I can tell Now, Bazel might use
Different kind of reproducibility. I guess I should have said "portability" instead. Ultimately, as a rule author, I don't want to have to write rules in one way when in Nixpkgs (which I can't detect reliably) and another elsewhere. As a developer, I don't want my users to have to pass extra flags on the command-line, or not, depending on their distribution. It's unclear to me whether that's still the case with your proposed changes. In any case, I submit that these are interesting changes but ought to be considered in a separate PR. |
Yeah absolutely, since there is a smaller change possible to upgrade the version that's what we should do first.
I see, that makes sense. I was interested in using Nix under macOS, so it's a very different situation: if Bazel works exactly like installed with brew, as in refers to the shell path either as defined in the calling environment or as defined as bash default, and uses a lot of binaries from there, then it's very hard to achieve reproducible builds when using it. Will close this PR and create a new one for darwin support once the upgrade has been merged on its own in #40205 or #40525. |
Motivation for this change
Update version.
Switch the existing bash hack with a patch that replaces all invocations of binaries assumed to be in the default bash path, /bin and /usr/bin with the absolute path to the binaries in the nix store.
Propagate
NIX_CFLAGS_COMPILE
andNIX_LDFLAGS
correctly to both the bootstrapping process and the bazel build definitions: both will clear the environment when invoking the cc and ld wrappers.Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)