-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3be72cf
commit 2a19f00
Showing
66 changed files
with
7,090 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Sensible Defaults | ||
build --sandbox_default_allow_network=false | ||
build --incompatible_strict_action_env | ||
build --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 | ||
build --incompatible_enable_cc_toolchain_resolution=true | ||
|
||
# Require Platform Transitions | ||
## This works by setting the targte platform to an invalid platform | ||
## and each `x_binary()` and `x_library()` rule unfortunately needs | ||
## to tag itself with `platform_missing` to get excluded from glob | ||
## builds like `build //...` but still have a way to include them | ||
## by removing the filter line for things like Rust Analyzer. | ||
build --host_platform=//bazel/platforms:host | ||
build --platforms=//bazel/platforms:missing | ||
build --build_tag_filters=-platform_missing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bazel-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
load("//bazel:transitions.bzl", "platform_transition_binary") | ||
|
||
# Disabled targets need the user to supply a sysroot in `flake.nix` first. | ||
|
||
# Explicit filegroup as globbed `//...` will skip targets without an error if | ||
# `cargo-bazel` doesn't generate a target for a given platform. | ||
filegroup( | ||
name = "nix_cross_compiling", | ||
srcs = [ | ||
# "cc_binary_aarch64-apple-darwin", | ||
# "cc_binary_aarch64-apple-ios", | ||
"cc_binary_aarch64-linux-android", | ||
"cc_binary_aarch64-unknown-linux-gnu", | ||
"cc_binary_wasm32-unknown-unknown", | ||
"cc_binary_wasm32-wasi", | ||
# "cc_binary_x86_64-apple-darwin", | ||
# "cc_binary_x86_64-pc-windows-msvc", | ||
"cc_binary_x86_64-unknown-linux-gnu", | ||
"cc_binary_x86_64-unknown-nixos-gnu", | ||
# "rust_binary_aarch64-apple-darwin", | ||
# "rust_binary_aarch64-apple-ios", | ||
"rust_binary_aarch64-linux-android", | ||
"rust_binary_aarch64-unknown-linux-gnu", | ||
"rust_binary_wasm32-unknown-unknown", | ||
"rust_binary_wasm32-wasi", | ||
# "rust_binary_x86_64-apple-darwin", | ||
# "rust_binary_x86_64-pc-windows-msvc", | ||
"rust_binary_x86_64-unknown-linux-gnu", | ||
"rust_binary_x86_64-unknown-nixos-gnu", | ||
], | ||
) | ||
|
||
# platform_transition_binary( | ||
# name = "cc_binary_aarch64-apple-darwin", | ||
# binary = "//cc_binary", | ||
# target_platform = "//bazel/platforms:aarch64-apple-darwin", | ||
# ) | ||
|
||
# platform_transition_binary( | ||
# name = "cc_binary_aarch64-apple-ios", | ||
# binary = "//cc_binary", | ||
# target_platform = "//bazel/platforms:aarch64-apple-ios", | ||
# ) | ||
|
||
platform_transition_binary( | ||
name = "cc_binary_aarch64-linux-android", | ||
binary = "//cc_binary", | ||
target_platform = "//bazel/platforms:aarch64-linux-android", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "cc_binary_aarch64-unknown-linux-gnu", | ||
binary = "//cc_binary", | ||
target_platform = "//bazel/platforms:aarch64-unknown-linux-gnu", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "cc_binary_wasm32-unknown-unknown", | ||
binary = "//cc_binary", | ||
target_platform = "//bazel/platforms:wasm32-unknown-unknown", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "cc_binary_wasm32-wasi", | ||
binary = "//cc_binary", | ||
target_platform = "//bazel/platforms:wasm32-wasi", | ||
) | ||
|
||
# platform_transition_binary( | ||
# name = "cc_binary_x86_64-apple-darwin", | ||
# binary = "//cc_binary", | ||
# target_platform = "//bazel/platforms:x86_64-apple-darwin", | ||
# ) | ||
|
||
# platform_transition_binary( | ||
# name = "cc_binary_x86_64-pc-windows-msvc", | ||
# binary = "//cc_binary", | ||
# target_platform = "//bazel/platforms:x86_64-pc-windows-msvc", | ||
# ) | ||
|
||
platform_transition_binary( | ||
name = "cc_binary_x86_64-unknown-linux-gnu", | ||
binary = "//cc_binary", | ||
target_platform = "//bazel/platforms:x86_64-unknown-linux-gnu", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "cc_binary_x86_64-unknown-nixos-gnu", | ||
binary = "//cc_binary", | ||
target_platform = "//bazel/platforms:x86_64-unknown-nixos-gnu", | ||
) | ||
|
||
# platform_transition_binary( | ||
# name = "rust_binary_aarch64-apple-darwin", | ||
# binary = "//rust_binary", | ||
# target_platform = "//bazel/platforms:aarch64-apple-darwin", | ||
# ) | ||
|
||
# platform_transition_binary( | ||
# name = "rust_binary_aarch64-apple-ios", | ||
# binary = "//rust_binary", | ||
# target_platform = "//bazel/platforms:aarch64-apple-ios", | ||
# ) | ||
|
||
platform_transition_binary( | ||
name = "rust_binary_aarch64-linux-android", | ||
binary = "//rust_binary", | ||
target_platform = "//bazel/platforms:aarch64-linux-android", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "rust_binary_aarch64-unknown-linux-gnu", | ||
binary = "//rust_binary", | ||
target_platform = "//bazel/platforms:aarch64-unknown-linux-gnu", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "rust_binary_wasm32-unknown-unknown", | ||
binary = "//rust_binary", | ||
target_platform = "//bazel/platforms:wasm32-unknown-unknown", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "rust_binary_wasm32-wasi", | ||
binary = "//rust_binary", | ||
target_platform = "//bazel/platforms:wasm32-wasi", | ||
) | ||
|
||
# platform_transition_binary( | ||
# name = "rust_binary_x86_64-apple-darwin", | ||
# binary = "//rust_binary", | ||
# target_platform = "//bazel/platforms:x86_64-apple-darwin", | ||
# ) | ||
|
||
# platform_transition_binary( | ||
# name = "rust_binary_x86_64-pc-windows-msvc", | ||
# binary = "//rust_binary", | ||
# target_platform = "//bazel/platforms:x86_64-pc-windows-msvc", | ||
# ) | ||
|
||
platform_transition_binary( | ||
name = "rust_binary_x86_64-unknown-linux-gnu", | ||
binary = "//rust_binary", | ||
target_platform = "//bazel/platforms:x86_64-unknown-linux-gnu", | ||
) | ||
|
||
platform_transition_binary( | ||
name = "rust_binary_x86_64-unknown-nixos-gnu", | ||
binary = "//rust_binary", | ||
target_platform = "//bazel/platforms:x86_64-unknown-nixos-gnu", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Nix + Bazel Cross Compiling | ||
|
||
Blog Post: <https://blog.consumingchaos.com/posts/nix-bazel-cross-compiling/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
# Nix | ||
http_archive( | ||
name = "io_tweag_rules_nixpkgs", | ||
sha256 = "657db2e70d933f252735a5a5c9f532c4cd5e77018b9d7256bc9c7b80a01e96b5", | ||
strip_prefix = "rules_nixpkgs-816e913f41d161659cbd1e49ff77694853398a3a", | ||
urls = ["https://github.com/tweag/rules_nixpkgs/archive/816e913f41d161659cbd1e49ff77694853398a3a.tar.gz"], | ||
) | ||
|
||
load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_dependencies") | ||
|
||
rules_nixpkgs_dependencies() | ||
|
||
load("//bazel:nix_repositories.bzl", "nix_repositories") | ||
|
||
nix_repositories() | ||
|
||
# Rust | ||
local_repository( | ||
name = "rules_rust", | ||
path = "../..", | ||
) | ||
|
||
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies") | ||
|
||
rules_rust_dependencies() | ||
|
||
load("@rules_rust//crate_universe:defs.bzl", "crates_repository", "render_config", "splicing_config") | ||
load("//bazel/cargo:crates_repository.bzl", CARGO_ANNOTATIONS = "ANNOTATIONS", CARGO_PACKAGES = "PACKAGES") | ||
|
||
crates_repository( | ||
name = "crate_index", | ||
annotations = CARGO_ANNOTATIONS, | ||
cargo_lockfile = "//bazel/cargo:Cargo.lock", | ||
generate_build_scripts = False, | ||
generator = "@cargo-bazel//:bin/cargo-bazel", | ||
lockfile = "//bazel/cargo:cargo-bazel-lock.json", | ||
packages = CARGO_PACKAGES, | ||
render_config = render_config( | ||
platforms_template = "@//bazel/cargo/platforms:{triple}", | ||
), | ||
rust_toolchain_cargo_template = "@nix_rust//:bin/{tool}", | ||
rust_toolchain_rustc_template = "@nix_rust//:bin/{tool}", | ||
splicing_config = splicing_config( | ||
resolver_version = "2", | ||
), | ||
supported_platform_triples = [ | ||
"aarch64-apple-darwin", | ||
"aarch64-apple-ios", | ||
"aarch64-linux-android", | ||
"aarch64-unknown-linux-gnu", | ||
"wasm32-unknown-unknown", | ||
"wasm32-wasi", | ||
"x86_64-apple-darwin", | ||
"x86_64-pc-windows-msvc", | ||
"x86_64-unknown-linux-gnu", | ||
], | ||
) | ||
|
||
load("@crate_index//:defs.bzl", "crate_repositories") | ||
|
||
crate_repositories() | ||
|
||
# Toolchains | ||
register_toolchains( | ||
"//bazel/toolchains/cc/aarch64-apple-darwin:toolchain", | ||
"//bazel/toolchains/cc/aarch64-apple-ios:toolchain", | ||
"//bazel/toolchains/cc/aarch64-linux-android:toolchain", | ||
"//bazel/toolchains/cc/aarch64-unknown-linux-gnu:toolchain", | ||
"//bazel/toolchains/cc/wasm32-unknown-unknown:toolchain", | ||
"//bazel/toolchains/cc/wasm32-wasi:toolchain", | ||
"//bazel/toolchains/cc/x86_64-apple-darwin:toolchain", | ||
"//bazel/toolchains/cc/x86_64-pc-windows-msvc:toolchain", | ||
"//bazel/toolchains/cc/x86_64-unknown-linux-gnu:toolchain", | ||
"//bazel/toolchains/cc/x86_64-unknown-nixos-gnu:toolchain", | ||
"//bazel/toolchains/rust/aarch64-apple-darwin:toolchain", | ||
"//bazel/toolchains/rust/aarch64-apple-ios:toolchain", | ||
"//bazel/toolchains/rust/aarch64-linux-android:toolchain", | ||
"//bazel/toolchains/rust/aarch64-unknown-linux-gnu:toolchain", | ||
"//bazel/toolchains/rust/wasm32-unknown-unknown:toolchain", | ||
"//bazel/toolchains/rust/wasm32-wasi:toolchain", | ||
"//bazel/toolchains/rust/x86_64-apple-darwin:toolchain", | ||
"//bazel/toolchains/rust/x86_64-pc-windows-msvc:toolchain", | ||
"//bazel/toolchains/rust/x86_64-unknown-linux-gnu:toolchain", | ||
"//bazel/toolchains/rust/x86_64-unknown-nixos-gnu:toolchain", | ||
) |
Empty file.
Empty file.
Oops, something went wrong.