I am trying to package verible, and I was able to (link), but I don’t think I have the correct way to do this.
enableNixHacks
I have been unable to get verible to build the same way as every other Bazel package.
By default buildBazelPackage
has enableNixHacks = true;
which adds this patch. The purpose of that patch is not clear to me (edit: I see now that is is for determinism when fetching assets).
If I disable the patch by putting bazel
in my native build inputs verible will build successfully.
nativeBuildInputs = [ bazel gcc jdk python3 ];
With the nix hacks (removing bazel
from nativeBuildInputs
) I get this failure:
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
ERROR: no such package '@bazel_tools//tools/build_defs/repo': to fix, run
bazel fetch //...
External repository @bazel_tools not found and fetching repositories is disabled.
Loading: 0 packages loaded
INFO: Elapsed time: 2.387s
Loading: 0 packages loaded
INFO: 0 processes.
Loading: 0 packages loaded
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
What is the purpose of this patch and why does enabling it cause a resolution error for the bazel_tools
external repository?
Following the Errors
For reference, if I follow the error message and enable fetching by removing "--nofetch"
in bazelBuildFlags = ["-c opt" "--nofetch"];
then Bazel tries to access the network within the sandbox which results in a different mode of failure:
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 30 packages loaded
Analyzing: 1839 targets (30 packages loaded, 0 targets configured)
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
Fetching @win_flex_bison; fetching
INFO: Repository win_flex_bison instantiated at:
/build/source/WORKSPACE:75:19: in <toplevel>
/build/source/bazel/win_flex_bison.bzl:110:26: in win_flex_configure
Repository rule remote_win_flex_bison defined at:
/build/source/bazel/win_flex_bison.bzl:100:40: in <toplevel>
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
Fetching @win_flex_bison; fetching
WARNING: Download from https://github.com/lexxmark/winflexbison/releases/download/v2.5.18/win_flex_bison-2.5.18.zip failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException Unknown host: github.com
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
ERROR: An error occurred during the fetch of repository 'win_flex_bison':
Traceback (most recent call last):
File "/build/source/bazel/win_flex_bison.bzl", line 90, column 40, in _remote_win_flex_bison
repository_ctx.download_and_extract(
Error in download_and_extract: java.io.IOException: Error downloading [https://github.com/lexxmark/winflexbison/releases/download/v2.5.18/win_flex_bison-2.5.18.zip] to /build/output/external/win_flex_bison/temp10671553611633039580/win_flex_bison-2.5.18.zip: Unknown host: github.com
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
ERROR: Analysis of target '//verilog/tools/syntax/export_json_examples:print_tree' failed; build aborted: java.io.IOException: Error downloading [https://github.com/lexxmark/winflexbison/releases/download/v2.5.18/win_flex_bison-2.5.18.zip] to /build/output/external/win_flex_bison/temp10671553611633039580/win_flex_bison-2.5.18.zip: Unknown host: github.com
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
INFO: Elapsed time: 3.230s
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
INFO: 0 processes.
Analyzing: 1839 targets (58 packages loaded, 536 targets configured)
FAILED: Build did NOT complete successfully (58 packages loaded, 536 targets c\
onfigured)
FAILED: Build did NOT complete successfully (58 packages loaded, 536 targets c\
onfigured)