Bazel: Difference between revisions

imported>Dmayle
Intial page on developing with Bazel on NixOS
 
Update deprecated function
Tags: Mobile edit Mobile web edit Visual edit
 
(5 intermediate revisions by 4 users not shown)
Line 7: Line 7:
   { pkgs ? import <nixpkgs> {} }:
   { pkgs ? import <nixpkgs> {} }:
    
    
   (pkgs.buildFHSUserEnv {
   (pkgs.buildFHSEnv {
     name = "bazel-userenv-example";
     name = "bazel-userenv-example";
     targetPkgs = pkgs: [
     targetPkgs = pkgs: [
Line 19: Line 19:


While there are solutions for simplifying the use of a shell.nix like direnv, lorri, and devenv, they are not compatible with a shell.nix that creates an FHS environment, since the FHS environment requires a sub-shell to properly setup the chroot, and the three tools above only support making changes to environment variables.
While there are solutions for simplifying the use of a shell.nix like direnv, lorri, and devenv, they are not compatible with a shell.nix that creates an FHS environment, since the FHS environment requires a sub-shell to properly setup the chroot, and the three tools above only support making changes to environment variables.
== Troubleshooting ==
In some versions of bazel, the sandboxing does not inherit the FHS environment, and elements of the toolchain (notably {{ic|protoc}}) may fail to run.  In that case, switching to {{ic|pkgs.bazel_4}} should solve the problem.
== See also ==
* [https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/build-bazel-package/default.nix buildBazelPackage implementation]
* [https://sourcegraph.com/search?q=context:global+buildBazelPackage+lang:nix+repo:%5Egithub%5C.com/NixOS/nixpkgs%24+&patternType=standard buildBazelPackage used in nixpkgs]
[[Category:Applications]]