1""" Nix Repositories """ 2 3load("@io_tweag_rules_nixpkgs//nixpkgs:nixpkgs.bzl", "nixpkgs_flake_package") 4 5_CONFIG_BUILD_FILE_CONTENT = """ 6package(default_visibility = ["//visibility:public"]) 7 8exports_files(["config.bzl"]) 9""" 10 11_RUST_BUILD_FILE_CONTENT = """ 12load("@rules_rust//rust:toolchain.bzl", "rust_stdlib_filegroup") 13 14package(default_visibility = ["//visibility:public"]) 15 16# https://github.com/tweag/rules_nixpkgs/blob/master/toolchains/rust/rust.bzl#L33-L116 17filegroup( 18 name = "rustc", 19 srcs = ["bin/rustc"], 20) 21 22filegroup( 23 name = "rustdoc", 24 srcs = ["bin/rustdoc"], 25) 26 27filegroup( 28 name = "rustfmt", 29 srcs = ["bin/rustfmt"], 30) 31 32filegroup( 33 name = "cargo", 34 srcs = ["bin/cargo"], 35) 36 37filegroup( 38 name = "clippy_driver", 39 srcs = ["bin/clippy-driver"], 40) 41 42filegroup( 43 name = "proc_macro_srv", 44 srcs = ["libexec/rust-analyzer-proc-macro-srv"], 45) 46 47filegroup( 48 name = "rustc_lib", 49 srcs = glob( 50 [ 51 "bin/*.so", 52 "lib/*.so", 53 "lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/*.so", 54 "lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/*.dylib", 55 "lib/rustlib/x86_64-unknown-linux-gnu/bin/*", 56 "lib/rustlib/x86_64-unknown-linux-gnu/lib/*.so", 57 "lib/rustlib/x86_64-unknown-linux-gnu/lib/*.dylib", 58 ], 59 allow_empty = True, 60 ), 61) 62 63filegroup( 64 name = "rust-src", 65 srcs = glob(["lib/rustlib/src/**/*"]), 66) 67 68rust_stdlib_filegroup( 69 name = "rust_std-aarch64-apple-darwin", 70 srcs = glob( 71 [ 72 "lib/rustlib/aarch64-apple-darwin/lib/*.rlib", 73 "lib/rustlib/aarch64-apple-darwin/lib/*.so", 74 "lib/rustlib/aarch64-apple-darwin/lib/*.dylib", 75 "lib/rustlib/aarch64-apple-darwin/lib/*.a", 76 "lib/rustlib/aarch64-apple-darwin/lib/self-contained/**", 77 ], 78 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 79 allow_empty = True, 80 ), 81) 82 83rust_stdlib_filegroup( 84 name = "rust_std-aarch64-apple-ios", 85 srcs = glob( 86 [ 87 "lib/rustlib/aarch64-apple-ios/lib/*.rlib", 88 "lib/rustlib/aarch64-apple-ios/lib/*.so", 89 "lib/rustlib/aarch64-apple-ios/lib/*.dylib", 90 "lib/rustlib/aarch64-apple-ios/lib/*.a", 91 "lib/rustlib/aarch64-apple-ios/lib/self-contained/**", 92 ], 93 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 94 allow_empty = True, 95 ), 96) 97 98rust_stdlib_filegroup( 99 name = "rust_std-aarch64-linux-android", 100 srcs = glob( 101 [ 102 "lib/rustlib/aarch64-linux-android/lib/*.rlib", 103 "lib/rustlib/aarch64-linux-android/lib/*.so", 104 "lib/rustlib/aarch64-linux-android/lib/*.dylib", 105 "lib/rustlib/aarch64-linux-android/lib/*.a", 106 "lib/rustlib/aarch64-linux-android/lib/self-contained/**", 107 ], 108 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 109 allow_empty = True, 110 ), 111) 112 113rust_stdlib_filegroup( 114 name = "rust_std-aarch64-unknown-linux-gnu", 115 srcs = glob( 116 [ 117 "lib/rustlib/aarch64-unknown-linux-gnu/lib/*.rlib", 118 "lib/rustlib/aarch64-unknown-linux-gnu/lib/*.so", 119 "lib/rustlib/aarch64-unknown-linux-gnu/lib/*.dylib", 120 "lib/rustlib/aarch64-unknown-linux-gnu/lib/*.a", 121 "lib/rustlib/aarch64-unknown-linux-gnu/lib/self-contained/**", 122 ], 123 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 124 allow_empty = True, 125 ), 126) 127 128rust_stdlib_filegroup( 129 name = "rust_std-wasm32-unknown-unknown", 130 srcs = glob( 131 [ 132 "lib/rustlib/wasm32-unknown-unknown/lib/*.rlib", 133 "lib/rustlib/wasm32-unknown-unknown/lib/*.so", 134 "lib/rustlib/wasm32-unknown-unknown/lib/*.dylib", 135 "lib/rustlib/wasm32-unknown-unknown/lib/*.a", 136 "lib/rustlib/wasm32-unknown-unknown/lib/self-contained/**", 137 ], 138 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 139 allow_empty = True, 140 ), 141) 142 143rust_stdlib_filegroup( 144 name = "rust_std-wasm32-wasi", 145 srcs = glob( 146 [ 147 "lib/rustlib/wasm32-wasi/lib/*.rlib", 148 "lib/rustlib/wasm32-wasi/lib/*.so", 149 "lib/rustlib/wasm32-wasi/lib/*.dylib", 150 "lib/rustlib/wasm32-wasi/lib/*.a", 151 "lib/rustlib/wasm32-wasi/lib/self-contained/**", 152 ], 153 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 154 allow_empty = True, 155 ), 156) 157 158rust_stdlib_filegroup( 159 name = "rust_std-x86_64-apple-darwin", 160 srcs = glob( 161 [ 162 "lib/rustlib/x86_64-apple-darwin/lib/*.rlib", 163 "lib/rustlib/x86_64-apple-darwin/lib/*.so", 164 "lib/rustlib/x86_64-apple-darwin/lib/*.dylib", 165 "lib/rustlib/x86_64-apple-darwin/lib/*.a", 166 "lib/rustlib/x86_64-apple-darwin/lib/self-contained/**", 167 ], 168 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 169 allow_empty = True, 170 ), 171) 172 173rust_stdlib_filegroup( 174 name = "rust_std-x86_64-pc-windows-msvc", 175 srcs = glob( 176 [ 177 "lib/rustlib/x86_64-pc-windows-msvc/lib/*.rlib", 178 "lib/rustlib/x86_64-pc-windows-msvc/lib/*.so", 179 "lib/rustlib/x86_64-pc-windows-msvc/lib/*.dylib", 180 "lib/rustlib/x86_64-pc-windows-msvc/lib/*.a", 181 "lib/rustlib/x86_64-pc-windows-msvc/lib/self-contained/**", 182 ], 183 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 184 allow_empty = True, 185 ), 186) 187 188rust_stdlib_filegroup( 189 name = "rust_std-x86_64-unknown-linux-gnu", 190 srcs = glob( 191 [ 192 "lib/rustlib/x86_64-unknown-linux-gnu/lib/*.rlib", 193 "lib/rustlib/x86_64-unknown-linux-gnu/lib/*.so", 194 "lib/rustlib/x86_64-unknown-linux-gnu/lib/*.dylib", 195 "lib/rustlib/x86_64-unknown-linux-gnu/lib/*.a", 196 "lib/rustlib/x86_64-unknown-linux-gnu/lib/self-contained/**", 197 ], 198 # Some patterns (e.g. `lib/*.a`) don't match anything, see https://github.com/bazelbuild/rules_rust/pull/245 199 allow_empty = True, 200 ), 201) 202""" 203 204def nix_repositories(): 205 nixpkgs_flake_package( 206 name = "nix_config", 207 nix_flake_file = "//nix:flake.nix", 208 nix_flake_lock_file = "//nix:flake.lock", 209 package = "bazel.config", 210 build_file_content = _CONFIG_BUILD_FILE_CONTENT, 211 ) 212 213 nixpkgs_flake_package( 214 name = "nix_rust", 215 nix_flake_file = "//nix:flake.nix", 216 nix_flake_lock_file = "//nix:flake.lock", 217 package = "bazel.rust", 218 build_file_content = _RUST_BUILD_FILE_CONTENT, 219 ) 220