|
| 1 | +module( |
| 2 | + name = "hello_world", |
| 3 | + version = "0.0.0", |
| 4 | +) |
| 5 | + |
| 6 | +bazel_dep(name = "rules_nixpkgs_core", version = "0.0.0") |
| 7 | +local_path_override( |
| 8 | + module_name = "rules_nixpkgs_core", |
| 9 | + path = "../../../core", |
| 10 | +) |
| 11 | + |
| 12 | +bazel_dep(name = "rules_nixpkgs_rust", version = "0.0.0") |
| 13 | +local_path_override( |
| 14 | + module_name = "rules_nixpkgs_rust", |
| 15 | + path = "../../../toolchains/rust", |
| 16 | +) |
| 17 | + |
| 18 | +bazel_dep(name = "rules_nixpkgs_cc", version = "0.0.0") |
| 19 | +local_path_override( |
| 20 | + module_name = "rules_nixpkgs_cc", |
| 21 | + path = "../../../toolchains/cc", |
| 22 | +) |
| 23 | + |
| 24 | +bazel_dep(name = "platforms", version = "1.0.0") |
| 25 | +bazel_dep(name = "rules_rust", version = "0.63.0") |
| 26 | + |
| 27 | +# rules_rust also uses the cc compiler |
| 28 | +bazel_dep(name = "rules_cc", version = "0.1.4") |
| 29 | + |
| 30 | +# |
| 31 | +# Nixpkgs |
| 32 | +# |
| 33 | + |
| 34 | +# It is recommended to keep nixpkgs of nix-shell (which provide Bazel), |
| 35 | +# and nixpkgs of Bazel Workspace in sync - otherwise one may |
| 36 | +# got hit with nasty glibc mismatch errors. |
| 37 | +nix_repo = use_extension("@rules_nixpkgs_core//extensions:repository.bzl", "nix_repo") |
| 38 | +nix_repo.file( |
| 39 | + name = "nixpkgs", |
| 40 | + file = "//:nixpkgs.nix", |
| 41 | + file_deps = [ |
| 42 | + "//:nixpkgs.json", |
| 43 | + ], |
| 44 | +) |
| 45 | +use_repo(nix_repo, "nixpkgs") |
| 46 | + |
| 47 | +nix_pkg = use_extension("@rules_nixpkgs_core//extensions:package.bzl", "nix_pkg") |
| 48 | +nix_pkg.file( |
| 49 | + name = "openssl-static", |
| 50 | + attr = "default", |
| 51 | + file = "//:openssl-static.nix", |
| 52 | + file_deps = [ |
| 53 | + "//:nixpkgs.json", |
| 54 | + ], |
| 55 | +) |
| 56 | +use_repo(nix_pkg, "openssl-static") |
| 57 | + |
| 58 | +# |
| 59 | +# Toolchains |
| 60 | +# |
| 61 | + |
| 62 | +cc_configure = use_extension("//:extension.bzl", "cc_configure") |
| 63 | +use_repo(cc_configure, "nixpkgs_config_cc") |
| 64 | +use_repo(cc_configure, "nixpkgs_config_cc_toolchains") |
| 65 | +use_repo(cc_configure, "nixpkgs_config_cc_info") |
| 66 | + |
| 67 | +register_toolchains("@nixpkgs_config_cc_toolchains//:all") |
| 68 | + |
| 69 | +rust_configure = use_extension("//:extension.bzl", "rust_configure") |
| 70 | +use_repo(rust_configure, "nixpkgs_rust") |
| 71 | +use_repo(rust_configure, "nixpkgs_rust_toolchain") |
| 72 | + |
| 73 | +register_toolchains("@nixpkgs_rust_toolchain//:rust_nix") |
| 74 | + |
| 75 | +# |
| 76 | +# Crates |
| 77 | +# |
| 78 | + |
| 79 | +crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") |
| 80 | +crate.annotation( |
| 81 | + build_script_data = [ |
| 82 | + "@openssl-static//:include", |
| 83 | + "@openssl-static//:lib", |
| 84 | + ], |
| 85 | + build_script_env = { |
| 86 | + "OPENSSL_INCLUDE_DIR": "../rules_nixpkgs_core~~nix_pkg~openssl-static/include", |
| 87 | + "OPENSSL_LIB_DIR": "../rules_nixpkgs_core~~nix_pkg~openssl-static/lib", |
| 88 | + "OPENSSL_STATIC": "1", |
| 89 | + }, |
| 90 | + crate = "openssl-sys", |
| 91 | + data = [ |
| 92 | + "@openssl-static//:include", |
| 93 | + "@openssl-static//:lib", |
| 94 | + ], |
| 95 | + rustc_flags = [ |
| 96 | + "-Lexternal/rules_nixpkgs_core~~nix_pkg~openssl-static/lib", |
| 97 | + ], |
| 98 | +) |
| 99 | +crate.spec( |
| 100 | + package = "openssl", |
| 101 | + version = "0.10.40", |
| 102 | +) |
| 103 | +crate.from_specs( |
| 104 | + cargo_lockfile = "//:Cargo.lock", |
| 105 | + lockfile = "//:cargo-bazel-lock.json", |
| 106 | +) |
| 107 | + |
| 108 | +inject_repo(crate, "openssl-static") |
| 109 | + |
| 110 | +use_repo(crate, "crates") |
0 commit comments