How to build software using bazel?


I’d love to build sorbet ruby type checker locally. I want to be able to just follow its existing build process:

I do not want to create a derivation for sorbet – this is just for my local exploration.

If I just run bazel build //main:sorbet --config=dbg though, I get

/home/matklad/.bazel_binaries/2.2.0/bin_t/bazel: error while loading shared libraries: cannot open shared object file: No such file or directory

Is there some easy trick to make this work?

1 Like

I think I might need to use the buildFHSUserEnv thing, but I was unable to find docs on how actually use it.

Ok managed to get further along by adding the following shell.nix to the project folder and running nix-shell shell.nix:

{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSUserEnv {
  name = "simple-x11-env";
  targetPkgs = pkgs: with pkgs; [ zlib ];
  runScript = "fish";

Now I face a bazel failure:

Unsupported linux distribution and version: nixos, 19.09.2190.84f47bfe9ae


1 Like

It looks like that error message is from some Bazel plugin trying to download LLVM 8? That’s probably not the right thing to do on NixOS anyway, so you should try switching to the host toolchain as in the link. If the default c++ doesn’t cut it, try mkShell.override { stdenv = llvmPackages_8.stdenv; }.

(edit: the override should work with buildFHSUserEnv as well)