-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preliminary bzlmod support #60
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
38552ed
Add bzlmod configuration to .bazelrc
aherrmann f68aada
bzlmod compatible rules_nixpkgs module names
aherrmann b2e09a6
Drop repository name on local labels
aherrmann e0e80c4
start MODULE.bazel files
aherrmann 6826588
gazelle_cabal non_module_deps
aherrmann 004cf9d
Declare gazelle_cabal Stackage dependencies
aherrmann 5c6294e
bzlmod: cc, posix, and haskell toolchain from Nix
aherrmann fee2a1d
example: import bzlmod stack snapshot
aherrmann 835a477
bzlmod: import zlib from Nix
aherrmann eea058c
import stackage-exe
aherrmann 791a4d2
tasty-discover components
aherrmann 9e2e2fb
Rearrange example module file
aherrmann 96f4a62
snapshots --> snapshot
aherrmann 6e99086
Enable bzlmod on CI
aherrmann 87deb68
Merge branch 'main' into bzlmod
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,21 @@ | ||
module( | ||
name = "gazelle_cabal", | ||
version = "0.0.0", | ||
) | ||
|
||
bazel_dep(name = "rules_haskell") | ||
|
||
stack_snapshot = use_extension( | ||
"@rules_haskell//extensions:stack_snapshot.bzl", | ||
"stack_snapshot", | ||
) | ||
use_repo(stack_snapshot, "stackage") | ||
stack_snapshot.package(name = "directory") | ||
stack_snapshot.package(name = "filepath") | ||
stack_snapshot.package(name = "json") | ||
|
||
non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps") | ||
use_repo(non_module_deps, "io_tweag_gazelle_cabal_deps") | ||
|
||
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") | ||
bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle") |
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
Empty file.
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,118 @@ | ||
module(name = "gazelle_cabal_example") | ||
|
||
bazel_dep(name = "gazelle_cabal", repo_name = "io_tweag_gazelle_cabal") | ||
local_path_override(module_name = "gazelle_cabal", path = "..") | ||
|
||
bazel_dep(name = "rules_haskell") | ||
bazel_dep(name = "rules_haskell_nix") | ||
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go") | ||
bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle") | ||
|
||
stack_snapshot = use_extension( | ||
"@rules_haskell//extensions:stack_snapshot.bzl", | ||
"stack_snapshot", | ||
) | ||
use_repo(stack_snapshot, "stackage", "stackage-exe") | ||
# TODO these should be generated by Gazelle | ||
stack_snapshot.package(name = "base") | ||
stack_snapshot.package(name = "inspection-testing") | ||
stack_snapshot.package(name = "mtl") | ||
stack_snapshot.package(name = "tasty") | ||
stack_snapshot.package( | ||
name = "tasty-discover", | ||
components = [ | ||
"lib", | ||
"exe:tasty-discover", | ||
], | ||
) | ||
stack_snapshot.package(name = "tasty-hunit") | ||
stack_snapshot.package(name = "text") | ||
stack_snapshot.package(name = "void") | ||
|
||
# TODO replace this once a proper public interface for Nix provided Haskell toolchains exists. | ||
nix_haskell_toolchains = use_extension( | ||
"@rules_haskell_nix//extensions:nix_haskell_toolchains.bzl", | ||
"nix_haskell_toolchains", | ||
) | ||
|
||
GHC_VERSION = "9.4.5" | ||
nix_haskell_toolchains.new( | ||
attribute_path = "haskell.compiler.ghc" + GHC_VERSION.replace(".", ""), | ||
repository = "@nixpkgs", | ||
version = GHC_VERSION, | ||
) | ||
use_repo( | ||
nix_haskell_toolchains, | ||
"nix_haskell_toolchains_configurations", | ||
# TODO register via rules_nixpkgs_posix once supported. | ||
"all_posix_toolchains", | ||
) | ||
|
||
# TODO remove this once a proper public interface for Nix provided Haskell toolchain exists. | ||
declare_nix_toolchains = use_extension( | ||
"@rules_haskell_nix//private:declare_toolchains.bzl", | ||
"declare_nix_toolchains", | ||
) | ||
use_repo( | ||
declare_nix_toolchains, | ||
"all_nix_toolchains", | ||
) | ||
|
||
register_toolchains( | ||
"@all_nix_toolchains//:all", | ||
"@all_posix_toolchains//:all", | ||
) | ||
|
||
# TODO Remove once rules_haskell is in the BCR. | ||
RULES_HASKELL_REV = "155ba21c7d315cc421ee3f17a1c09b758cc7279d" | ||
RULES_HASKELL_INTEGRITY = "sha384-dIsFufYml0KGSUiC6jhY9ClMv/yEW1kGof7fLahSwfbWd28jLiwMGBGUuoOsQwWf" | ||
archive_override( | ||
module_name = "rules_haskell", | ||
urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % RULES_HASKELL_REV], | ||
strip_prefix = "rules_haskell-%s" % RULES_HASKELL_REV, | ||
integrity = RULES_HASKELL_INTEGRITY, | ||
) | ||
archive_override( | ||
module_name = "rules_haskell_nix", | ||
urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % RULES_HASKELL_REV], | ||
strip_prefix = "rules_haskell-%s/rules_haskell_nix" % RULES_HASKELL_REV, | ||
integrity = RULES_HASKELL_INTEGRITY, | ||
) | ||
|
||
# Needed for custom toolchain definitions in non_module_deps. | ||
# TODO update once a bzlmod API for Nix provided toolchains exists. | ||
bazel_dep(name = "rules_nixpkgs_core") | ||
bazel_dep(name = "rules_nixpkgs_cc") | ||
bazel_dep(name = "rules_nixpkgs_posix") | ||
bazel_dep(name = "platforms", version = "0.0.7") | ||
bazel_dep(name = "rules_cc", version = "0.0.9") | ||
|
||
# TODO Remove once rules_nixpkgs is in the BCR. | ||
RULES_NIXPKGS_REV = "7e627d76ba65d6c42586fc265e46bd370672b4eb" | ||
RULES_NIXPKGS_INTEGRITY = "sha384-N2bS5BvSk8QMjhmuxdeeve9PBJUTwFOHufMV4sDgaviwXNdCGc7JaJPqwqZV1TbC" | ||
archive_override( | ||
module_name = "rules_nixpkgs_core", | ||
urls = ["https://github.com/tweag/rules_nixpkgs/archive/%s.tar.gz" % RULES_NIXPKGS_REV], | ||
strip_prefix = "rules_nixpkgs-%s/core" % RULES_NIXPKGS_REV, | ||
integrity = RULES_NIXPKGS_INTEGRITY, | ||
) | ||
archive_override( | ||
module_name = "rules_nixpkgs_cc", | ||
urls = ["https://github.com/tweag/rules_nixpkgs/archive/%s.tar.gz" % RULES_NIXPKGS_REV], | ||
strip_prefix = "rules_nixpkgs-%s/toolchains/cc" % RULES_NIXPKGS_REV, | ||
integrity = RULES_NIXPKGS_INTEGRITY, | ||
) | ||
archive_override( | ||
module_name = "rules_nixpkgs_posix", | ||
urls = ["https://github.com/tweag/rules_nixpkgs/archive/%s.tar.gz" % RULES_NIXPKGS_REV], | ||
strip_prefix = "rules_nixpkgs-%s/toolchains/posix" % RULES_NIXPKGS_REV, | ||
integrity = RULES_NIXPKGS_INTEGRITY, | ||
) | ||
|
||
non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps") | ||
use_repo(non_module_deps, "nixpkgs") | ||
use_repo(non_module_deps, "nixpkgs_config_cc") | ||
use_repo(non_module_deps, "nixpkgs_config_cc_info") | ||
use_repo(non_module_deps, "nixpkgs_config_cc_toolchains") | ||
use_repo(non_module_deps, "zlib.dev") | ||
register_toolchains("@nixpkgs_config_cc_toolchains//:all") |
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
Empty file.
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,57 @@ | ||
load( | ||
"@rules_nixpkgs_core//:nixpkgs.bzl", | ||
"nixpkgs_local_repository", | ||
"nixpkgs_package", | ||
) | ||
load("@rules_nixpkgs_cc//:cc.bzl", "nixpkgs_cc_configure") | ||
|
||
def _non_module_deps_impl(_ctx): | ||
nixpkgs_local_repository( | ||
name = "nixpkgs", | ||
nix_file = "//:nixpkgs.nix", | ||
) | ||
|
||
nixpkgs_cc_configure( | ||
name = "nixpkgs_config_cc", | ||
repository = "@nixpkgs", | ||
register = False, | ||
) | ||
|
||
nixpkgs_package( | ||
name = "nixpkgs_zlib", | ||
attribute_path = "zlib", | ||
repository = "@nixpkgs", | ||
) | ||
|
||
nixpkgs_package( | ||
name = "zlib.dev", | ||
build_file_content = """ | ||
load("@rules_cc//cc:defs.bzl", "cc_library") | ||
|
||
filegroup( | ||
name = "include", | ||
srcs = glob(["include/*.h"]), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "zlib", | ||
srcs = ["@nixpkgs_zlib//:lib"], | ||
hdrs = [":include"], | ||
strip_include_prefix = "include", | ||
visibility = ["//visibility:public"], | ||
# This rule only bundles headers and a library and doesn't compile or link by itself. | ||
# We set linkstatic = 1 to quiet to quiet the following warning: | ||
# | ||
# in linkstatic attribute of cc_library rule @zlib.dev//:zlib: | ||
# setting 'linkstatic=1' is recommended if there are no object files. | ||
# | ||
linkstatic = 1, | ||
) | ||
""", | ||
repository = "@nixpkgs", | ||
) | ||
|
||
non_module_deps = module_extension( | ||
implementation = _non_module_deps_impl, | ||
) |
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,11 @@ | ||
load("//:defs.bzl", "gazelle_cabal_dependencies") | ||
|
||
def _non_module_deps_impl(_ctx): | ||
# TODO[AH]: This is only required for backward compatibility to WORKSPACE mode. | ||
# Once WORKSPACE mode support is removed we can directly reference the | ||
# `@stackage//...` labels for the dependencies introduced by this macro. | ||
gazelle_cabal_dependencies() | ||
|
||
non_module_deps = module_extension( | ||
implementation = _non_module_deps_impl, | ||
) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's nicer 👍