Skip to content

Commit

Permalink
build rules_nixpkgs_core compatibly in isolation
Browse files Browse the repository at this point in the history
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]: #181
  • Loading branch information
fricklerhandwerk committed Mar 17, 2022
1 parent c819f2d commit b14a697
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
35 changes: 35 additions & 0 deletions core/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
build --host_platform=@rules_nixpkgs_core//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
65 changes: 63 additions & 2 deletions core/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,63 @@
# only temporary for compatibility with `WORKSPACE` setup
# TODO: remove when migration to `bzlmod` is complete
# 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("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure")
load("@rules_nixpkgs_java//:java.bzl", "nixpkgs_java_configure")

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(
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",
)

0 comments on commit b14a697

Please sign in to comment.