Snapshot and package location¶
This document describes:
- the specification of a snapshot location (in the
- the specification of a package location (in the
extra-depskey and in a snapshot)
Stack uses the Pantry to specify the location of snapshots and packages. Pantry is geared towards reproducible build plans with cryptographically secure specification of snapshots and packages.
There are essentially four different ways of specifying a snapshot location:
Via a compiler version, which is a "compiler only" snapshot. This could be, for example:
Via a URL pointing to a snapshot configuration file, for example:
Via a local file path pointing to a snapshot configuration file, for example:
Via a convenience synonym, which provides a short form for some common URLs. These are:
github:user/repo:pathis treated as:
lts-X.Yis treated (by default) as:
nightly-YYYY-MM-DDis treated (by default) as:
By default, LTS Haskell and Stackage Nightly snapshot configurations are
retrieved from the
stackage-snapshots GitHub repository of user
option allows a custom location to be set.
For safer, more reproducible builds, you can optionally specify a URL together with a cryptographic hash of its content. For example:
size is the number of bytes in the file and
sha256 is the file's SHA256
hash. If not provided, the information will automatically be generated and
stored in a lock file.
There are three types of package locations:
- Hackage packages
- Git and Mecurial repositories
- Local or remote archives (such as GitHub archives)
All three types support optional tree metadata to be added, which can be used for reproducibility and faster downloads. This information can automatically be generated in a lock file.
A package can be identified by its name, version and Cabal file revision
number, with revision
0 being the original Cabal file. For example:
A package name and version only can be stated. Using this syntax, the most recent Cabal file revision available in the package index will be used. For example:
This syntax is often used in practice, but may result in one build differing from another, if a new or further Cabal file revision is added to the package index between the builds.
As an alternative to specifying the Cabal file revision number, you can specify the package name and version with the SHA256 hash of the contents of its Cabal file. Doing so is slightly more resilient than using the Cabal file revision number, as it does not rely on the correct ordering in the package index. For example:
Optionally, you can specify also the size of the Cabal file in bytes. For
example (where the file size is
Optionally, you can specify also the Pantry tree information. For example:
A Pantry tree is a list of CAS (content-addressable storage) 'SHA256 hash'-'size in bytes' keys for each of the files in a package.
The SHA256 hash of the contents of the Cabal file and its size in bytes is provided in Stack's lock file. For further information, see the lock files documentation. The SHA256 hash and file size alternative is also what Stack uses when it makes suggestions about missing packages.
Git and Mercurial repositories¶
You can specify a Git or Mercurial repository at a specific commit, and Stack will clone that repository and, if it has submodules (Git), update the repository's submodules. For example:
It is highly recommended that you only use SHA1 values for a Git or Mercurial commit. Other values may work, but they are not officially supported, and may result in unexpected behavior (namely, Stack will not automatically pull to update to new versions). Another problem with this is that your build will not be deterministic, because when someone else tries to build the project they can get a different checkout of the package.
commit: key expects a YAML string. A commit hash, or partial hash,
comprised only of digits represents a YAML number, unless it is enclosed in
For the contents of a Git repository, Stack cannot handle filepaths or
symbolic link names that are longer than those supported by the
(Unix Standard TAR) archive format defined by
git archive to convert the content of a Git repository to a
TAR archive, which it then seeks to consume. Git produces
archives which use 'extended' headers for matters that the
cannot handle. Unfortunately, Stack cannot consume an extended header and
will silently discard the item.
A common practice in the Haskell world is to use "megarepos", or repositories
with multiple packages in various subdirectories. Some common examples include
support this, you may also specify
subdirs for repositories. For example:
subdirs defaults to
['.'] meaning looking for a package in
the root of the repository. If you specify a value of
not included by default and needs to be explicitly specified if a required
package is found in the top-level directory of the repository.
git-annex is not supported. This is because
git archive does not handle symbolic links outside the work tree. It is still
possible to use repositories which use git-annex but do not require the annex
files for the package to be built.
For example, if the directory
fonts/ is controlled by git-annex, use the
Local or remote archives (such as GitHub archives)¶
Filepaths or URLs to archive files¶
You can use filepaths referring to local archive files or HTTP or HTTPS URLs referring to remote archive files, either tarballs or ZIP files.
Stack assumes that these archive files never change after downloading to avoid needing to make an HTTP request on each build.
For safer, more reproducible builds, you can optionally specify a cryptographic hash of the archive file.
GitHub archive files¶
You can specify a GitHub respository at a specific commit and Stack will obtain from GitHub an archive file of the files in the repository at that point in its history. For example:
An archive file of the files in a GitHub repository at a point in its history is not the same as a clone of the repository (including its history) and the updating of any submodules. If you need the latter, use the syntax for a Git repository.
If the package fails to build due to missing files, it may be that updated submodules are required.