From 99cad542606f41880f3fd0bc0ae10056d64cc8ed Mon Sep 17 00:00:00 2001 From: Adam Szady <7527999+aszady@users.noreply.github.com> Date: Wed, 14 Jan 2026 20:23:37 +0100 Subject: [PATCH] Allow customizing alias creation macro For more complex scenarios, where default behaviour doesn't match user needs. --- bazeldnf/extensions.bzl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bazeldnf/extensions.bzl b/bazeldnf/extensions.bzl index 837ac450..92096dc1 100644 --- a/bazeldnf/extensions.bzl +++ b/bazeldnf/extensions.bzl @@ -65,7 +65,7 @@ bazeldnf_toolchain = module_extension( ) _ALIAS_TEMPLATE = """\ -load("@bazeldnf//bazeldnf:alias_macros.bzl", aliases="default") +load("{macro_file}", aliases="{macro_name}") aliases( name = "{name}", @@ -124,10 +124,13 @@ def _alias_repository_impl(repository_ctx): ), ) + macro_file, macro_name = repository_ctx.attr.alias_macro.split("%", 1) for name, metadata in repository_ctx.attr.packages_metadata.items(): repository_ctx.file( "%s/BUILD.bazel" % name, _ALIAS_TEMPLATE.format( + macro_file = macro_file, + macro_name = macro_name, name = name, data = metadata, ), @@ -154,6 +157,7 @@ _alias_repository = repository_rule( "nobest": attr.bool(default = False), "cache_dir": attr.string(), "architectures": attr.string_list(), + "alias_macro": attr.string(), }, ) @@ -180,6 +184,7 @@ def _handle_lock_file(config, module_ctx, registered_rpms = {}): "repository_prefix": config.rpm_repository_prefix, "nobest": config.nobest, "architectures": _get_architectures(config.architecture, config.architectures), + "alias_macro": config.alias_macro, } module_ctx.watch(config.lock_file) @@ -414,6 +419,13 @@ The lock file content is as: with the first one having the highest priority. `noarch` is implicitly added at the end (if not present on the list).""", ), + "alias_macro": attr.string( + default = "@bazeldnf//bazeldnf:alias_macros.bzl%default", + doc = """Implementation of a macro generating aliases in the generated proxy repository. + + Specify it in format: <.bzl file label>% + Explore the default implementation and the meaning of args in `bazeldnf/alias_macros.bzl`.""", + ), }, )