Is your feature request related to a problem? Please describe.
Bazel supports remote execution through the remote execution protocol. This protocol manages inputs and outputs required by and generated by Bazel build actions, i.e. actions defined by regular Bazel rules.
However, rules_nixpkgs defines repository rules that invoke nix-build during Bazel's loading phase. The Nix package manager will then realize Nix store paths (typically under /nix/store/...) and generate symlinks into Bazel's execution root. These Nix store paths are outside of Bazel's control and the remote execution protocol does not ensure that these store paths are also realized on the remote execution nodes.
Remote execution actions that depend on Nix store paths will fail if the required Nix store paths are not realized on the remote execution nodes.
Describe the solution you'd like
We need some solution to ensure that Nix store paths that are required for Bazel build actions exist on the remote execution nodes that these actions may be run on.
Some possible approaches:
- Run a script before each Bazel invocation (e.g. by defining a custom
tools/bazel) that builds all required Nix store paths on the remote execution nodes.
- Remote execution nodes could share a Nix store via network fs.
nixpkgs_package could set remotable = True to execute the nix-build command on the remote execution nodes. (feature announcement, commit, flag)
- Remote execution could be configured to run actions in Docker images that contain the needed Nix store paths, perhaps using Nixery.
- Place the Nix store inside Bazel's execroot (perhaps using managed directories) and add a sandbox mount pair (should support relative paths) to mount it under
/nix/store inside the sandbox.
cc @YorikSar @AleksanderGondek @r2r-dev
Is your feature request related to a problem? Please describe.
Bazel supports remote execution through the remote execution protocol. This protocol manages inputs and outputs required by and generated by Bazel build actions, i.e. actions defined by regular Bazel rules.
However,
rules_nixpkgsdefines repository rules that invokenix-buildduring Bazel's loading phase. The Nix package manager will then realize Nix store paths (typically under/nix/store/...) and generate symlinks into Bazel's execution root. These Nix store paths are outside of Bazel's control and the remote execution protocol does not ensure that these store paths are also realized on the remote execution nodes.Remote execution actions that depend on Nix store paths will fail if the required Nix store paths are not realized on the remote execution nodes.
Describe the solution you'd like
We need some solution to ensure that Nix store paths that are required for Bazel build actions exist on the remote execution nodes that these actions may be run on.
Some possible approaches:
tools/bazel) that builds all required Nix store paths on the remote execution nodes.nixpkgs_packagecould setremotable = Trueto execute thenix-buildcommand on the remote execution nodes. (feature announcement, commit, flag)/nix/storeinside the sandbox.cc @YorikSar @AleksanderGondek @r2r-dev