commercialhaskell / commercialhaskell/stack

Proposal: Dependency vendoring for Stack

Open
#3,813 6 comments 3 reactions 0 assignees View on GitHub
component: build type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

# Dependency vendoring for Stack

## Use cases
With vendored dependencies we get the capability to build, test & run a Haskell project without access to either Hackage or Stackage.

1. Get a project from version control and start working without internet connectivity (local, offline development)
2. Build a project on a remote machine without internet access (Bosh release)
3. Build a project on a remote machine without internet access and with limited local disk space (Cloud Foundry buildpack)

## Problem
Stack has to get the Hackage index and download all dependency packages prior to building. As a workaround for use case use case 1 we can `stack build --prefetch --dry-run` to get everything local. As a workaround for use case 2 we can create a tarball from stack-root. However the creation is rather inconvenient and the result larger than we want.

## Solution
The recently released extensible snapshot work can be used as basis for complete offline builds with limited file system usage. We can download all dependency packages (`stack list-dependencies` and remove ghc package db packages) and list them in a snapshot referring only to `ghc-x.y.z` snapshot.
Given an existing GHC we can use the snapshot and `--system-ghc` to build without any internet access.

Doing what is described as solution from outside of stack is inconvenient though. That is why we propose to add a command to stack:

```
stack vendor-dependencies [--path ]
```
The command should download the dependency packages for all targets to (which should default to `/vendored`) and create a snapshot YAML at `/vendored.yml` including all the downloaded packages and referring to the ghc resolver used by .

## Limitations
We do not propose to vendor ghc itself because that is system dependent. As a consequence GHC has to be provided out of band.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.