Skip to content

Commit 71688d8

Browse files
committed
Tidy up snapshot/package location and snapshot specification
1 parent 493f01c commit 71688d8

File tree

3 files changed

+268
-204
lines changed

3 files changed

+268
-204
lines changed

doc/custom_snapshot.md

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,135 @@
11
<div class="hidden-warning"><a href="https://docs.haskellstack.org/"><img src="https://cdn.jsdelivr.net/gh/commercialhaskell/stack/doc/img/hidden-warning.svg"></a></div>
22

3-
# Custom Snapshots
3+
## Snapshot specification
44

5-
This content has been moved to the [docs on pantry](pantry.md).
5+
[:octicons-tag-24: 2.1.1](https://github.com/commercialhaskell/stack/releases/tag/v2.1.1)
6+
7+
Snapshots provide a list of packages to use, along with flags, GHC options, and
8+
a few other settings. Snapshots may extend any other snapshot that can be
9+
specified in a `resolver` or `snapshot` key. The packages specified follow the
10+
same syntax for dependencies in Stack's project-level configuration files.
11+
Unlike the `extra-deps` key, however, no support for local directories is
12+
available in snapshots to ensure reproducibility.
13+
14+
!!! info
15+
16+
Stack uses the [Pantry](https://hackage.haskell.org/package/pantry) for
17+
snapshot specification.
18+
19+
~~~yaml
20+
resolver: lts-8.21 # Inherits GHC version and package set
21+
compiler: ghc-8.0.1 # Overwrites GHC version in the resolver, optional
22+
23+
# Additional packages, follows extra-deps syntax
24+
packages:
25+
- unordered-containers-0.2.7.1
26+
- hashable-1.2.4.0
27+
- text-1.2.2.1
28+
29+
# Packages from the parent snapshot to ignore
30+
drop-packages:
31+
- wai-extra
32+
33+
# Packages which should be hidden
34+
hidden:
35+
wai: true
36+
warp: false
37+
38+
# Set GHC options for specific packages
39+
ghc-options:
40+
warp:
41+
- -O2
42+
43+
# Override flags, can also override flags in the parent snapshot
44+
flags:
45+
unordered-containers:
46+
debug: true
47+
~~~
48+
49+
If you put this in a `snapshot.yaml` file in the same directory as your project,
50+
you can now use the snapshot like this:
51+
52+
~~~yaml
53+
resolver: snapshot.yaml
54+
~~~
55+
56+
This is an example of a custom snapshot stored in the filesystem. They are
57+
assumed to be mutable, so you are free to modify it. We detect that the snapshot
58+
has changed by hashing the contents of the involved files, and using it to
59+
identify the snapshot internally. It is often reasonably efficient to modify a
60+
custom snapshot, due to Stack sharing snapshot packages whenever possible.
61+
62+
### Overriding the compiler
63+
64+
The following snapshot specification will be identical to `lts-7.1`, but instead
65+
use `ghc-7.10.3` instead of `ghc-8.0.1`:
66+
67+
~~~yaml
68+
resolver: lts-7.1
69+
compiler: ghc-7.10.3
70+
~~~
71+
72+
### Dropping packages
73+
74+
The following snapshot specification will be identical to `lts-7.1`, but without
75+
the `text` package in our snapshot. Removing this package will cause all the
76+
packages that depend on `text` to be unbuildable, but they will still be present
77+
in the snapshot.
78+
79+
~~~yaml
80+
resolver: lts-7.1
81+
drop-packages:
82+
- text
83+
~~~
84+
85+
### Hiding packages
86+
87+
The following snapshot specification will be identical to `lts-7.1`, but the
88+
`text` package will be hidden when registering. This will affect, for example,
89+
the import parser in the script command.
90+
91+
~~~yaml
92+
resolver: lts-7.1
93+
hidden:
94+
- text
95+
~~~
96+
97+
### Specifying GHC options
98+
99+
In order to specify GHC options for a package, you use the same syntax as the
100+
[ghc-options](yaml_configuration.md#ghc-options) key for build configuration.
101+
102+
The following snapshot specification will be identical to `lts-7.1`, but
103+
provides `-O1` as a ghc-option for `text`:
104+
105+
~~~yaml
106+
resolver: lts-7.1
107+
packages:
108+
- text-1.2.2.1
109+
ghc-options:
110+
text: -O1
111+
~~~
112+
113+
This works somewhat differently than the stack.yaml `ghc-options` field, in that
114+
options can only be specified for packages that are mentioned in the custom
115+
snapshot's `packages` list. It sets the ghc-options, rather than extending those
116+
specified in the snapshot being extended.
117+
118+
Another difference is that the `*` entry for `ghc-options` applies to all
119+
packages in the `packages` list, rather than all packages in the snapshot.
120+
121+
### Specifying Cabal flags
122+
123+
In order to specify Cabal flags for a package, you use the same syntax as the
124+
[flags](yaml_configuration.md#flags) key for build configuration. The
125+
following snapshot specification will be identical to `lts-7.1`, but
126+
it enables the `developer` Cabal flag:
127+
128+
~~~yaml
129+
resolver: lts-7.1
130+
packages:
131+
- text-1.2.2.1
132+
flags:
133+
text:
134+
developer: true
135+
~~~

0 commit comments

Comments
 (0)