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

Enable pinning and better caching with stack_snapshot #1310

Closed
aherrmann opened this issue Apr 22, 2020 · 2 comments · Fixed by #1376
Closed

Enable pinning and better caching with stack_snapshot #1310

aherrmann opened this issue Apr 22, 2020 · 2 comments · Fixed by #1376

Comments

@aherrmann
Copy link
Member

Is your feature request related to a problem? Please describe.

stack_snapshot calls out to stack at every fetch multiple times:

  • stack update in order to update the Hackage database (factored out into stack_update).
  • stack unpack to download the package sources.
  • stack ls dependencies and stack dot to determine the dependency graph.

This causes some issues:

Describe the solution you'd like

I would like stack_snapshot to be more transparent for Bazel. The new stack ls dependencies json feature provides most of the required information: The package name, version, dependencies, and the package location (Hackage, URL, repository). We could then use download_and_extract or git_repo to let Bazel fetch the sources in a way that Bazel can cache.

Unfortunately, stack ls dependencies json does not provide the sha256. However, Bazel gives access to the sha256 after the download, so we could generate a lock file containing the sha256 (or the commit and shallow_since in case of git_repo).

Similar to rules_jvm_external I would like stack_snapshot to provide a pinning mechanism. Given a lock file stack_snapshot would not have to call out to stack at all, avoiding any of the issues around stack update.

Describe alternatives you've considered

  • Instead of shelling out to stack we could also implement a dedicated tool using the pantry library. However, this causes a bootstrapping issue.
  • Cache the stackage snapshot repository #1168 proposes to generate a tarball bundling all sources fetched by stack unpack and enabling stack_snapshot to download that from a user defined remote cache instead of calling stack unpack. However, this would probably require a fair bit of setup from the user's side and is not a solution that would be easily applicable by most users. To avoid any call to stack this would also need to generate some form of lock file that provides the required package metadata.

Additional context

@mboes
Copy link
Member

mboes commented Aug 5, 2020

@aherrmann do I understand correctly that if the SHA256 was exposed in stack ls dependencies json (as suggested in commercialhaskell/stack#5274), that the //:pin script would no longer be necessary?

@aherrmann
Copy link
Member Author

The pin script itself is just a small script that copies the lock file into the user's repository (similar to rules_jvm_external). So, we'd probably keep that script if stack exposed the sha256. However, we could simplify the generation of the lock file if we didn't have to query all-cabal-hashes or download archive dependencies to determine hashes ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants