Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions modules/rules_pkl/0.13.0/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""apple/rules_pkl"""

module(
name = "rules_pkl",
version = "0.13.0",
bazel_compatibility = [">=7.0.0"],
compatibility_level = 1,
)

bazel_dep(name = "aspect_bazel_lib", version = "2.13.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_java", version = "8.11.0")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "rules_shell", version = "0.4.0")

bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.44.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "rules_bazel_integration_test", version = "0.34.0", dev_dependency = True)
bazel_dep(name = "rules_python", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)

pkl = use_extension("//pkl/extensions:pkl.bzl", "pkl")
use_repo(
pkl,
"pkl-cli-linux-aarch64",
"pkl-cli-linux-amd64",
"pkl-cli-macos-aarch64",
"pkl-cli-macos-amd64",
)

register_toolchains(
"@rules_pkl//pkl:pkl_toolchain_codegen_java",
"@rules_pkl//pkl:pkl_toolchain_linux_aarch64",
"@rules_pkl//pkl:pkl_toolchain_linux_amd64",
"@rules_pkl//pkl:pkl_toolchain_macos_aarch64",
"@rules_pkl//pkl:pkl_toolchain_macos_amd64",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "rules_pkl_deps",
artifacts = [
"com.google.code.gson:gson:2.13.1",
"org.jetbrains.kotlin:kotlin-stdlib:2.0.21",
"org.junit.vintage:junit-vintage-engine:5.13.4",
"org.pkl-lang:pkl-config-java:0.29.1",
"org.pkl-lang:pkl-tools:0.29.1",
],
lock_file = "//pkl/private:pkl_deps_install.json",
repositories = [
"https://repo1.maven.org/maven2/",
],
)
use_repo(
maven,
"rules_pkl_deps",
"unpinned_rules_pkl_deps",
)

maven.install(
name = "custom_pkl_java_library_maven_deps",
artifacts = [
"org.pkl-lang:pkl-config-java:0.29.1",
],
lock_file = "//pkl/private:pkl_deps_custom_java_library_maven_deps_install.json",
repositories = [
"https://repo1.maven.org/maven2/",
],
)
use_repo(
maven,
"custom_pkl_java_library_maven_deps",
"unpinned_custom_pkl_java_library_maven_deps",
)

python = use_extension(
"@rules_python//python/extensions:python.bzl",
"python",
dev_dependency = True,
)
python.toolchain(
configure_coverage_tool = True,
ignore_root_user_error = True,
python_version = "3.12",
)

bazel_binaries = use_extension(
"@rules_bazel_integration_test//:extensions.bzl",
"bazel_binaries",
dev_dependency = True,
)
bazel_binaries.download(version = "7.6.1")
bazel_binaries.download(version = "8.2.1")
use_repo(
bazel_binaries,
"bazel_binaries",
"bazel_binaries_bazelisk",
"build_bazel_bazel_7_6_1",
"build_bazel_bazel_8_2_1",
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

hawkeye_coordinates = [
{
"name": "hawkeye-aarch64-apple-darwin",
"url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-aarch64-apple-darwin.tar.xz",
"sha256": "9f300ad84201e500c4eb09ed710239797d2a6a17de5b7c08e1d3af1704ca6bb7",
},
{
"name": "hawkeye-x86_64-apple-darwin",
"url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-apple-darwin.tar.xz",
"sha256": "6f8850adb9204b6218f4912fb987106a71fcd8d742ce20227697ddccc44cec38",
},
{
"name": "hawkeye-x86_64-unknown-linux-gnu",
"url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-unknown-linux-gnu.tar.xz",
"sha256": "d5b9d3cdb4293ac84fa27e5021c77b6c062c61071760ab05fcacfbec1ac14850",
},
]

[
http_archive(
name = coords["name"],
build_file = "//scripts:hawkeye.BUILD",
sha256 = coords["sha256"],
strip_prefix = coords["name"],
url = coords["url"],
)
for coords in hawkeye_coordinates
]
Comment on lines +117 to +146
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using http_archive at the top level of a MODULE.bazel file is discouraged. These repository rules are ignored when rules_pkl is used as a transitive dependency, which makes them behave like development dependencies. However, this is not the idiomatic way to declare dev dependencies in bzlmod and can be confusing.

The correct approach is to move this logic into a module extension defined in a .bzl file, and then use that extension with dev_dependency = True.

For example, you could create a //tools:extensions.bzl file in your repository:

# //tools:extensions.bzl

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

hawkeye_coordinates = [
    {
        "name": "hawkeye-aarch64-apple-darwin",
        "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-aarch64-apple-darwin.tar.xz",
        "sha256": "9f300ad84201e500c4eb09ed710239797d2a6a17de5b7c08e1d3af1704ca6bb7",
    },
    {
        "name": "hawkeye-x86_64-apple-darwin",
        "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-apple-darwin.tar.xz",
        "sha256": "6f8850adb9204b6218f4912fb987106a71fcd8d742ce20227697ddccc44cec38",
    },
    {
        "name": "hawkeye-x86_64-unknown-linux-gnu",
        "url": "https://github.com/korandoru/hawkeye/releases/download/v6.0.2/hawkeye-x86_64-unknown-linux-gnu.tar.xz",
        "sha256": "d5b9d3cdb4293ac84fa27e5021c77b6c062c61071760ab05fcacfbec1ac14850",
    },
]

def _dev_tools_impl(_ctx):
    for coords in hawkeye_coordinates:
        http_archive(
            name = coords["name"],
            build_file = "//scripts:hawkeye.BUILD",
            sha256 = coords["sha256"],
            strip_prefix = coords["name"],
            url = coords["url"],
        )

dev_tools = module_extension(implementation = _dev_tools_impl)

And then in MODULE.bazel:

# MODULE.bazel

dev_tools = use_extension("//tools:extensions.bzl", "dev_tools", dev_dependency = True)
use_repo(
    dev_tools,
    "hawkeye-aarch64-apple-darwin",
    "hawkeye-x86_64-apple-darwin",
    "hawkeye-x86_64-unknown-linux-gnu",
)

This makes it explicit that hawkeye is a development dependency and aligns with modern bzlmod best practices.

34 changes: 34 additions & 0 deletions modules/rules_pkl/0.13.0/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
matrix:
platform:
- debian11
- ubuntu2204
- macos
- macos_arm64
bazel:
- 8.x
- 7.x
tasks:
verify_targets:
name: Verify build targets
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- '@rules_pkl//pkl/...'
bcr_test_module:
module_path: examples
matrix:
platform:
- debian11
- ubuntu2204
- macos
- macos_arm64
bazel:
- 8.x
- 7.x
tasks:
run_test_module:
name: Run test module
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- //...
5 changes: 5 additions & 0 deletions modules/rules_pkl/0.13.0/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"url": "https://github.com/apple/rules_pkl/releases/download/v0.13.0/rules_pkl-0.13.0.tar.gz",
"integrity": "sha256-47aOcdfUZl1i6JfHlDhaCHFRqnlzkAMJmuh9tdWe35Y=",
"strip_prefix": "rules_pkl-0.13.0"
}
5 changes: 3 additions & 2 deletions modules/rules_pkl/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"email": "simon@rueggs.ch",
"github": "srueg",
"github_user_id": 1105286,
"name": "Simon Rüegg"
"name": "Simon R\u00fcegg"
}
],
"repository": [
Expand All @@ -63,7 +63,8 @@
"0.9.0",
"0.10.0",
"0.11.1",
"0.12.0"
"0.12.0",
"0.13.0"
],
"yanked_versions": {}
}
Loading