Skip to content

Commit d2c700f

Browse files
committed
Fix #6035 Improve extra-dep and lock files documentation
1 parent 2b44bb8 commit d2c700f

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

doc/global_flags.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ Default: `read-write`, if snapshot specified in YAML configuration file;
118118
`read-only`, if a different snapshot is specified on the command line.
119119

120120
Pass the option `--lock-file <mode>` to specify how Stack interacts with lock
121-
files. Valid modes are `error-on-write`, `ignore`, `read-only` and `read-write`.
121+
files. Valid modes are:
122+
123+
* `error-on-write`: Stack reports an error, rather than write a lock file;
124+
* `ignore`: Stack ignores lock files;
125+
* `read-only`: Stack only reads lock files; and
126+
* `read-write`: Stack reads and writes lock files.
122127

123128
## `--[no-]modify-code-page` flag
124129

doc/lock_files.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,40 @@ packages:
145145
sha256: 614bc0cca76937507ea0a5ccc17a504c997ce458d7f2f9e43b15a10c8eaeb033
146146
~~~
147147

148-
## Creation
148+
## Creation procedure
149149

150150
Whenever a project-level configuration file (`stack.yaml`) is loaded, Stack
151151
checks for a lock file in the same file path, with a `.lock` extension added.
152152
For example, if you command:
153153

154154
~~~text
155-
stack build --stack-yaml my-stack.yaml
155+
stack --stack-yaml my-stack.yaml build
156156
~~~
157157

158-
Stack will use a lock file in the location `my-stack.yaml.lock`. For the rest of
159-
this document, we'll assume that the files are simply `stack.yaml` and
158+
or
159+
160+
~~~text
161+
stack --stack-yaml my-stack.yaml build --dry-run
162+
~~~
163+
164+
then Stack will use a lock file in the location `my-stack.yaml.lock`. For the
165+
rest of this document, we'll assume that the files are simply `stack.yaml` and
160166
`stack.yaml.lock`.
161167

162-
If the lock file does not exist, it will be created by:
168+
If the lock file does not exist, subject to Stack's
169+
[`--lock-file`](global_flags.md#-lock-file-option) option, it will be
170+
created by:
163171

164172
* Loading the `stack.yaml`
165173
* Loading all snapshot files
166174
* Completing all missing information
167-
* Writing out the new `stack.yaml.lock` file
175+
* Writing out the new `stack.yaml.lock` file to the disk
168176

169177
## Update procedure
170178

171-
When loading a Stack project all completed package or snapshot locations (even
172-
when they were completed using information from a lock file) get collected to
173-
form a new lock file in memory and compare against the one on disk, writing if
174-
there are any differences.
179+
Whenever a project-level configuration file (`stack.yaml`) is loaded, all
180+
completed package or snapshot locations (even those completed using information
181+
from a lock file) get collected to form a new lock file in memory. Subject to
182+
Stack's [`--lock-file`](global_flags.md#-lock-file-option) option, that new lock
183+
file is compared against the one on disk and, if there are any differences,
184+
written out to the disk.

doc/pantry.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -98,49 +98,45 @@ generated in a [lock file](lock_files.md).
9898

9999
### Hackage packages
100100

101-
Packages can be stated by a name-version combination. The basic syntax for this
102-
is:
101+
A package can be identified by its name, version and its Cabal file revision
102+
number, with `0` being the original Cabal file. For example:
103103

104104
~~~yaml
105105
extra-deps:
106-
- acme-missiles-0.3
106+
- acme-missiles-0.3@rev:0
107107
~~~
108108

109-
Using this syntax, the most recent Cabal file revision available will
110-
be used.
111-
112-
You can specify a specific revision number, with `0` being the original file,
113-
like this:
109+
A package name and version only can be stated. Using this syntax, the most
110+
recent Cabal file revision available in the package index will be used. For
111+
example:
114112

115113
~~~yaml
116114
extra-deps:
117-
- acme-missiles-0.3@rev:0
115+
- acme-missiles-0.3
118116
~~~
119117

120-
For safer, more reproducible builds, you can optionally specify the SHA256 hash
121-
of the Cabal file's contents, like this:
118+
This may result in one build differing from another, if a further Cabal file
119+
revision is added to the package index between builds.
120+
121+
Alternatively, you can specify the package name and version with the SHA256 hash
122+
of the contents of its Cabal file. Doing so is slighly more resilient than using
123+
the Cabal file revision number, as it does not rely on the correct ordering in
124+
the package index. For example:
122125

123126
~~~yaml
124127
extra-deps:
125128
- acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1
126129
~~~
127130

128-
You can optionally also specify the size of the Cabal file in bytes, like this:
131+
Optionally, you can specify also the size of the Cabal file in bytes. For
132+
example:
129133

130134
~~~yaml
131135
extra-deps:
132136
- acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1,631
133137
~~~
134138

135-
!!! note
136-
137-
Specifying package using SHA256 is slightly more resilient in that it does
138-
not rely on correct ordering in the package index, while revision number is
139-
likely simpler to use. In practice, both should guarantee equally
140-
reproducible build plans.
141-
142-
You can also include the Pantry tree information. The following would be
143-
generated and stored in the lock file:
139+
Optionally, you can specify also the Pantry tree information. For example:
144140

145141
~~~yaml
146142
- hackage: acme-missiles-0.3@sha256:2ba66a092a32593880a87fb00f3213762d7bca65a687d45965778deb8694c5d1,613
@@ -149,6 +145,10 @@ generated and stored in the lock file:
149145
sha256: 614bc0cca76937507ea0a5ccc17a504c997ce458d7f2f9e43b15a10c8eaeb033
150146
~~~
151147

148+
The SHA256 hash of the contents of the Cabal file and its size in bytes is
149+
provided in Stack's lock file. For further information, see the
150+
[lock files](lock_files.md) documentation.
151+
152152
### Git and Mercurial repositories
153153

154154
You can give a Git or Mercurial repository at a specific commit, and Stack will

0 commit comments

Comments
 (0)