Open YorikSar opened 2 years ago
Note that currently we test in CI:
--config=nix
in nix-shell
with only Bazel declared in shell.nix
files (5.x for Java example, 4.x for all others), but it also pulls in other nix-shell
stuff like compiler (that makes my error go away)--config=nix
outside nix-shell
which uses Bazel from environment (5.x for both Ubuntu and macOS in GitHub Actions images) that uses compiler from environment and doesn't break with gcc is not installed
for some reason.It seems like by these tests we imply that:
rules_nixpkgs
version can only be used in nix-shell
environment (without --pure
), which is not true, it works fine outside (if configured properly)--config=nix
, we can run "without Nix", which is not true, because rules_nixpkgs
in WORKSPACE will run nix-build
anywayIt looks like GitHub Actions provide Bazelisk, so we might want to switch to pinning Bazel version using Bazelisk and letting rules_nixpkgs
fetch everything that's needed if --config=nix
is specified.
@aherrmann @layus ping
It looks like GitHub Actions provide Bazelisk, so we might want to switch to pinning Bazel version using Bazelisk and letting rules_nixpkgs fetch everything that's needed if --config=nix is specified.
I think we should focus our efforts on two use-cases:
These combinations should be well tested in CI, if they are not in some cases, then this is a bug and needs to be fixed. And, yes, this also includes covering more Bazel versions, something that we don't currently do, but should do.
Other combinations:
As for rules_nixpkgs's behavior in unsupported configurations. It's not so easy to determine automatically which configuration Bazel is run in. There are tricks like checking whether nix-build
is in PATH
or whether IN_NIX_SHELL
(exact spelling might differ) is set, but, inevitably these are not complete. Therefore, rules_nixpkgs relies on use configuration. In particular, on users setting a Bazel platform that includes the @rules_nixpkgs_core//constraints:support_nix
constraint. Note, --config=nix
or similar is something that is specific to each individual project's .bazelrc
configuration. The configuration in .bazelrc
is not inherited through rule-set dependencies.
@YorikSar can you try this now after the changes of #286? It may be that the .bazelrc
change is sufficient to fix the issue, but I don't have a macOS device at hand to try.
@YorikSar are you able to check whether this issue still occurs after @evertedsphere's changes?
Describe the bug Example in
examples/toolchains/cc
fails if I run it withbazel run --config=nix :hello
:To Reproduce
Expected behavior We shouldn't expect user to always run examples in nix-shell, but rather they should work with system Bazel and ensure reproducibility with Nix via
rules_nixpkgs
, so this should work the same as innix-shell
environment.Environment
Additional context It seems examples don't actually use
nixpkgs_config_cc
provided byrules_nixpkgs
, they uselocal_config_cc
instead. It looks like this is because of missing flag--incompatible_enable_cc_toolchain_resolution
in config (see https://github.com/bazelbuild/bazel/issues/7260). We should probably turn it on in examples and test our code outsidenix-shell
as well.