Make stack_snapshot usable from another's module extension #1906
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.
Depends on #1905
This PR makes the
stack_snapshot
repository rule usable from anon_module_dep
extension of another module thanrules_haskell
(such asrules_haskell_tests
).These changes are needed because with bzlmod, when
stack_snapshot
is called by an extension of another module, rules_haskell does not have visibility of generated repositories (such asrules_haskell_stack
) and cannot build labels to its targets using theLabel
constructor.To work around this, an optional
label_builder
parameter can be passed tostack_snapshot
, which can be used to build labels from the context of the caller modules extension and obtain their canonical names. Once we provide our own module extension to install stackage packages (Add a module extension for Stackage packages #1899), thislabel_builder
parameter should not be necessary anymore.For the same reason, the
stack_update
attribute to_stack_snapshot
is now always present (so we do not have to hardcode its label), and is made into a string so that we only fetch thestack_update
repository when explicitly reading from it.