From 26c0668d885aabe6145faf79cfc7f109e3efb1d2 Mon Sep 17 00:00:00 2001 From: fricklerhandwerk Date: Wed, 16 Mar 2022 13:58:38 +0100 Subject: [PATCH] build `rules_nixpkgs_core` compatibly in isolation ideally we would already operate within `bzlmod` here, but we do not even have all dependencies present in [BCR][bcr] as of today. it is another can of worms detailed in [#181][181]. here we just isolate `rules_nixpkgs_core` as a proper self-contained repository as far as possible. [bcr]: https://github.com/bazelbuild/bazel-central-registry/tree/92bb87fc41d549a47297af67c4135111308b7b03 [181]: https://github.com/tweag/rules_nixpkgs/issues/181 --- core/.bazelrc | 35 +++++++++++++++++++++++ core/WORKSPACE | 77 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 core/.bazelrc diff --git a/core/.bazelrc b/core/.bazelrc new file mode 100644 index 000000000..17718a597 --- /dev/null +++ b/core/.bazelrc @@ -0,0 +1,35 @@ +build --host_platform=//platforms:host + +# NOTE: all of the following is copy-pasted from `/.bazelrc` and necessary to +# make this repository work compatibly in isolation. + +build --crosstool_top=@nixpkgs_config_cc//:toolchain +# Using toolchain resolution can lead to spurious dependencies on +# `@local_config_cc//:builtin_include_directory_paths`. This needs to be +# resolved before `--incompatible_enable_cc_toolchain_resolution` can be +# recommended for `nixpkgs_cc_configure_hermetic`. +# build --incompatible_enable_cc_toolchain_resolution + +build --javabase=@nixpkgs_java_runtime//:runtime +build --host_javabase=@nixpkgs_java_runtime//:runtime +build --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 +build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8 + +# CI Configuration +# ---------------- +common:ci --color=no +build:ci --verbose_failures +test:ci --test_output=errors + +# Use a remote cache during CI +build:ci --bes_results_url=https://app.buildbuddy.io/invocation/ +build:ci --bes_backend=grpcs://cloud.buildbuddy.io +build:ci --remote_cache=grpcs://cloud.buildbuddy.io +build:ci --remote_timeout=3600 +# Avoid failures of the form `deadline exceeded after 14999958197ns DEADLINE_EXCEEDED`. +# See https://github.com/tweag/rules_haskell/issues/1498. +build:ci --keep_backend_build_event_connections_alive=false + +# User Configuration +# ------------------ +try-import %workspace%/.bazelrc.local diff --git a/core/WORKSPACE b/core/WORKSPACE index a69f72f2c..e7a67e748 100644 --- a/core/WORKSPACE +++ b/core/WORKSPACE @@ -1,2 +1,75 @@ -# only temporary for compatibility with `WORKSPACE` setup -# TODO: remove when migration to `bzlmod` is complete \ No newline at end of file +# NOTE: only temporary for compatibility with `WORKSPACE` setup! +# TODO: remove when migration to `bzlmod` is completelocal_repository + + +# NOTE: all of the following is copy-pasted from `/WORKSPACE` and reduced +# to the necessary to make this repository work compatibly in isolation. + +# TODO: remove dependency on cumulative repository to be sure there is no +# hidden entanglement left. use individual toolchains instead. +local_repository( + name = "io_tweag_rules_nixpkgs", + path = "..", +) + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_dependencies") + +rules_nixpkgs_dependencies() + +load( + "//:nixpkgs.bzl", + "nixpkgs_git_repository", + "nixpkgs_local_repository", +) + +load( + "@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", + "nixpkgs_cc_configure", + "nixpkgs_java_configure", +) + +# For documentation + +http_archive( + name = "io_bazel_stardoc", + sha256 = "6d07d18c15abb0f6d393adbd6075cd661a2219faab56a9517741f0fc755f6f3c", + strip_prefix = "stardoc-0.4.0", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/stardoc/archive/0.4.0.tar.gz", + "https://github.com/bazelbuild/stardoc/archive/0.4.0.tar.gz", + ], +) + +load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories") + +stardoc_repositories() + +nixpkgs_git_repository( + name = "remote_nixpkgs", + remote = "https://github.com/NixOS/nixpkgs", + revision = "21.11", + sha256 = "c77bb41cf5dd82f4718fa789d49363f512bb6fa6bc25f8d60902fe2d698ed7cc", +) + +nixpkgs_local_repository( + name = "nixpkgs", + nix_file = "@io_tweag_rules_nixpkgs//:nixpkgs.nix", + nix_file_deps = ["@io_tweag_rules_nixpkgs//:nixpkgs.json"], +) + +nixpkgs_cc_configure( + # Use a different name to be able to distinguish this toolchain from the + # builtin one in the tests. + name = "nixpkgs_config_cc", + repository = "@remote_nixpkgs", +) + +load("@rules_java//java:repositories.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +nixpkgs_java_configure( + attribute_path = "jdk8.home", + repository = "@remote_nixpkgs", +)