Skip to content

Hermetic (offline) build of enola with Nix and Bazel #1730

@dotdoom

Description

@dotdoom

We're making a nix-bazel-nix sandwich:

  1. Nix runs bazel to fetch all dependencies, then tars them and supply it as derivation to next step
  2. Nix builds the app (offline)

According to https://bazel.build/external/faq#how-do-i-prepare-and-run-an-offline-build this should work:

$ bazel clean

$ REGISTRY=$(mktemp -d)
$ git clone https://github.com/bazelbuild/bazel-central-registry.git "${REGISTRY?}"

$ REPO_CACHE=$(mktemp -d)
$ TARGET=//java/dev/enola/cli:enola_deploy.jar
$ bazel --batch fetch --repository_cache="${REPO_CACHE?}" --registry="file://${REGISTRY?}" "${TARGET?}"

< disconnect network >

$ bazel --batch build --nofetch --repository_cache="${REPO_CACHE?}" --registry="file://${REGISTRY?}" "${TARGET?}"

However on Nix this doesn't work at build:

       > OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
       > Computing main repo mapping:
       > ERROR: Error computing the main repository mapping: error during computation of main repo mapping: to fix, run
       >  bazel fetch //...
       > External repository @@bazel_tools not found and fetching repositories is disabled.
       > Computing main repo mapping:

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions