Skip to content
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

Support defining multiple stackage snapshots in module extension #1960

Open
avdv opened this issue Sep 15, 2023 · 1 comment
Open

Support defining multiple stackage snapshots in module extension #1960

avdv opened this issue Sep 15, 2023 · 1 comment
Assignees
Labels
P3 minor: not priorized

Comments

@avdv
Copy link
Member

avdv commented Sep 15, 2023

Currently, there is no way to configure a stack_snapshot other than the default "stackage" one in a MODULE.bazel file.

Adding an attribute to the configuration tags by which we are able to identify and configure different snapshots would make a MODULE.bazel file look like this:

stackage = use_extension("@rules_haskell//extension:stackage_snapshot.bzl", "stack_snapshot")

stackage.snapshot(name = "stackage", local_snapshot = ...)

stackage.snapshot(name = "other-snapshot", local_snapshot = ...)

stackage.package(name = "vector") # default snapshot
stackage.package(name = "vector", snapshot = "stackage") # equivalent to the above

stackage.package(name = "megaparsec", snapshot = "other-snapshot")

use_repo(
  stackage,
  "stackage",
  "stackage-exe",
  "other-snapshot",
  "other-snapshot-exe"
)
@avdv avdv self-assigned this Sep 15, 2023
@avdv avdv changed the title Support to define multiple stackage snapshots in module extenson Support to define multiple stackage snapshots in module extension Sep 15, 2023
@avdv avdv changed the title Support to define multiple stackage snapshots in module extension Support defining multiple stackage snapshots in module extension Sep 15, 2023
avdv added a commit that referenced this issue Sep 15, 2023
Add a `name` to the stack_snapshot tag which can be referenced from other tags
of the extension using the `snapshot` attribute.

The tags are then grouped by the snapshot name, and a stack snapshot is created.
Only the first snapshot sets up the global stack tool repository.

Fixes #1960
@avdv
Copy link
Member Author

avdv commented Sep 20, 2023

Given that there is an experimental isolate argument for the use_extension function in Bazel >= 6.3.0 (under the --experimental_isolated_extension_usages flag) it seems that this would be a better mechanism to support this use case.

In the meantime (if you cannot / do not want to use isolate = True), define auxiliary stack snapshots in an extension implementation.

See https://bazel.build/rules/lib/globals/module#use_extension and bazelbuild/bazel#18529

@avdv avdv added the P3 minor: not priorized label Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 minor: not priorized
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant