Merge pull request #9050 from haskell/mergify/bp/3.10/pr-8952
[cabal.git] / doc / cabal-project.rst
blob2e47dfdc53caa821f73eaba69f6219bbba367b2d
1 cabal.project Reference
2 =======================
4 ``cabal.project`` files support a variety of options which configure the
5 details of your build. The general syntax of a ``cabal.project`` file is
6 similar to that of a Cabal file: there are a number of fields, some of
7 which live inside stanzas (groups of fields that apply to only part of a
8 project or can be referenced as a unit):
12     packages: */*.cabal
13     with-compiler: /opt/ghc/8.0.1/bin/ghc
15     package cryptohash
16       optimization: False
18 In general, the accepted field names coincide with the accepted command
19 line flags that ``cabal install`` and other commands take. For example,
20 ``cabal configure --enable-profiling`` will write out a project
21 file with ``profiling: True``.
23 The full configuration of a project is determined by combining the
24 following sources (later entries override earlier ones, except for appendable
25 options):
27 1. :ref:`The user-wide global configuration <config-file-discovery>` (default: ``~/.config/cabal/config``)
29 2. ``cabal.project`` (the project configuration)
31 3. ``cabal.project.freeze`` (the output of ``cabal freeze``)
33 4. ``cabal.project.local`` (the output of ``cabal configure``)
35 Any call to ``cabal build`` will consider ``cabal.project*`` files from parent
36 directories when there is none in the current directory.
38 .. _conditionals and imports:
40 Conditionals and imports
41 ------------------------
43 As of ``cabal-install`` version 3.8, cabal supports conditional logic
44 and imports in ``cabal.project`` files. :ref:`conditions` in cabal
45 may case on operating system, architecture, and
46 compiler (i.e. there is no support for a notion of custom flags in
47 project files). Imports may specify local filepaths or remote urls,
48 and may reference either cabal.project files or v1-style cabal.config
49 freeze files. As a usage example:
53     if(os(darwin))
54       optimization: False
55     elif(os(freebsd))
56       packages: freebsd/*.cabal
57     else
58       optimization: True
60     import: https://some.remote.source/subdir/cabal.config
62     import: relativepath/extra-project.project
64     import: /absolutepath/some-project.project
66 Using conditionals will force cabal to find a ghc to derive
67 architecture and version information from, which will force some
68 commands (update, sdist) to require ghc present where otherwise it
69 would not be necessitated.
71 Specifying the local packages
72 -----------------------------
74 The following top-level options specify what the local packages of a
75 project are:
77 .. cfg-field:: packages: package location list (space or comma separated)
78     :synopsis: Project packages.
80     :default: ``./*.cabal``
82     .. warning::
84       The default value ``./*.cabal`` only takes effect if there is no explicit
85       ``cabal.project`` file.
86       If you use such explicit file you *must* fill the field.
88     Specifies the list of package locations which contain the local
89     packages to be built by this project. Package locations can take the
90     following forms:
92     1. They can specify a Cabal file, or a directory containing a Cabal
93        file, e.g., ``packages: Cabal cabal-install/cabal-install.cabal``.
95     2. They can specify glob-style wildcards, which must match one or
96        more (a) directories containing a (single) Cabal file, (b) Cabal
97        files (extension ``.cabal``), or (c) tarballs which contain Cabal
98        packages (extension ``.tar.gz``).
99        For example, to match all Cabal files in all
100        subdirectories, as well as the Cabal projects in the parent
101        directories ``foo`` and ``bar``, use
102        ``packages: */*.cabal ../{foo,bar}/``
104     3. They can specify an ``http``, ``https`` or ``file``
105        URL, representing the path to a remote tarball to be downloaded
106        and built.
108     There is no command line variant of this field; see :issue:`3585`.
109     Note that the default value is only included if there is no
110     ``cabal.project`` file. The field is appendable which means there would be
111     no way to drop the default value if it was included.
113 .. cfg-field:: optional-packages: package location list (space or comma-separated)
114     :synopsis: Optional project packages.
116     :default: empty
118     Like :cfg-field:`packages`, specifies a list of package locations
119     containing local packages to be built. Unlike :cfg-field:`packages`,
120     if we glob for a package, it is permissible for the glob to match against
121     zero packages. The intended use-case for :cfg-field:`optional-packages`
122     is to make it so that vendored packages can be automatically picked up if
123     they are placed in a subdirectory, but not error if there aren't any.
125     There is no command line variant of this field.
127 .. cfg-field:: extra-packages: package list with version bounds (comma separated)
128     :synopsis: Adds external packages as local
130     Specifies a list of external packages from Hackage, which
131     should be considered local packages. The motivation for
132     :cfg-field:`extra-packages` is making libraries that are not
133     dependencies of any package in the project available for use in ghci.
135     There is no command line variant of this field.
139 All local packages are *vendored*, in the sense that if other packages
140 (including external ones from Hackage) depend on a package with the name
141 of a local package, the local package is preferentially used.
142 For subdirectories to be considered local packages, the following setting
143 can be used::
145     packages: ./*.cabal
146     optional-packages: ./*/*.cabal
148 ...then any package can be vendored simply by making a checkout in the
149 top-level project directory, as might be seen in this hypothetical
150 directory layout::
152     foo.cabal
153     foo-helper/     # local package
154     unix/           # vendored external package
156 All of these options support globs. ``cabal build`` has its own glob
157 format:
159 -  Anywhere in a path, as many times as you like, you can specify an
160    asterisk ``*`` wildcard. E.g., ``*/*.cabal`` matches all ``.cabal``
161    files in all immediate subdirectories. Like in glob(7), asterisks do
162    not match hidden files unless there is an explicit period, e.g.,
163    ``.*/foo.cabal`` will match ``.private/foo.cabal`` (but
164    ``*/foo.cabal`` will not).
166 -  You can use braces to specify specific directories; e.g.,
167    ``{vendor,pkgs}/*.cabal`` matches all Cabal files in the ``vendor``
168    and ``pkgs`` subdirectories.
170 Formally, the format is described by the following BNF:
172 .. todo::
173     convert globbing grammar to proper ABNF_ syntax
175 .. code-block:: abnf
177     FilePathGlob    ::= FilePathRoot FilePathGlobRel
178     FilePathRoot    ::= {- empty -}        # relative to cabal.project
179                       | "/"                # Unix root
180                       | [a-zA-Z] ":" [/\\] # Windows root
181                       | "~"                # home directory
182     FilePathGlobRel ::= Glob "/"  FilePathGlobRel # Unix directory
183                       | Glob "\\" FilePathGlobRel # Windows directory
184                       | Glob         # file
185                       | {- empty -}  # trailing slash
186     Glob      ::= GlobPiece *
187     GlobPiece ::= "*"            # wildcard
188                 | [^*{},/\\] *   # literal string
189                 | "\\" [*{},]    # escaped reserved character
190                 | "{" Glob "," ... "," Glob "}" # union (match any of these)
193 Specifying Packages from Remote Version Control Locations
194 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196 Starting with Cabal 2.4, there is now a stanza
197 ``source-repository-package`` for specifying packages from an external
198 version control.
200 .. code-block:: cabal
202     packages: .
204     source-repository-package
205         type: git
206         location: https://github.com/hvr/HsYAML.git
207         tag: e70cf0c171c9a586b62b3f75d72f1591e4e6aaa1
209     source-repository-package
210         type: git
211         location: https://github.com/well-typed/cborg
212         tag: 3d274c14ca3077c3a081ba7ad57c5182da65c8c1
213         subdir: cborg
215     source-repository-package
216         type: git
217         location: https://github.com/haskell/network.git
218         tag: e76fdc753e660dfa615af6c8b6a2ad9ddf6afe70
219         post-checkout-command: autoreconf -i
221 cabal-install 3.4 sdists the ``source-repository-package`` repositories and uses resulting tarballs as project packages.
222 This allows sharing of packages across different projects.
224 .. cfg-field:: type: VCS kind
226 .. cfg-field:: location: VCS location (usually URL)
228 .. cfg-field:: tag: VCS tag
230 .. cfg-field:: subdir: subdirectory list
232     Use one or more subdirectories of the repository.
234 .. cfg-field:: post-checkout-command: command
236     Run command in the checked out repository, prior sdisting.
238 Global configuration options
239 ----------------------------
241 The following top-level configuration options are not specific to any
242 package, and thus apply globally:
245 .. cfg-field:: verbose: nat
246                --verbose=n, -vn
247     :synopsis: Build verbosity level.
249     :default: 1
251     Control the verbosity of ``cabal`` commands, valid values are from 0
252     to 3.
254     The command line variant of this field is ``--verbose=2``; a short
255     form ``-v2`` is also supported.
257 .. cfg-field:: jobs: nat or $ncpus
258                --jobs=n, -jn, --jobs=$ncpus
259     :synopsis: Number of builds running in parallel.
261     :default: 1
263     Run *nat* jobs simultaneously when building. If ``$ncpus`` is
264     specified, run the number of jobs equal to the number of CPUs.
265     Package building is often quite parallel, so turning on parallelism
266     can speed up build times quite a bit!
268     The command line variant of this field is ``--jobs=2``; a short form
269     ``-j2`` is also supported; a bare ``--jobs`` or ``-j`` is equivalent
270     to ``--jobs=$ncpus``.
272 .. cfg-field::  keep-going: boolean
273                 --keep-going
274     :synopsis: Try to continue building on failure.
276     :default: False
278     If true, after a build failure, continue to build other unaffected
279     packages.
281     The command line variant of this field is ``--keep-going``.
283 .. option:: --builddir=DIR
285     Specifies the name of the directory where build products for
286     build will be stored; defaults to ``dist-newstyle``.  If a
287     relative name is specified, this directory is resolved relative
288     to the root of the project (i.e., where the ``cabal.project``
289     file lives.)
291     This option cannot be specified via a ``cabal.project`` file.
293 .. _cmdoption-project-file:
294 .. option:: --project-file=FILE
296     Specifies the name of the project file used to specify the
297     rest of the top-level configuration; defaults to ``cabal.project``.
298     This name not only specifies the name of the main project file,
299     but also the auxiliary project files ``cabal.project.freeze``
300     and ``cabal.project.local``; for example, if you specify
301     ``--project-file=my.project``, then the other files that will
302     be probed are ``my.project.freeze`` and ``my.project.local``.
304     If the specified project file is a relative path, we will
305     look for the file relative to the current working directory,
306     and then for the parent directory, until the project file is
307     found or we have hit the top of the user's home directory.
309     This option cannot be specified via a ``cabal.project`` file.
311 .. option:: --ignore-project
313     Ignores the local ``cabal.project`` file and uses the default
314     configuration with the local ``foo.cabal`` file. Note that
315     if this flag is set while the ``--project-file`` flag is also
316     set then this flag will be ignored.
318 .. option:: --store-dir=DIR
320     Specifies the name of the directory of the global package store.
322 .. cfg-field:: package-dbs: package DB stack (comma separated)
323                --package-db=[clear, global, user, PATH]
324     :synopsis: PackageDB stack manipulation
325     :since: 3.7
327     There are three package databases involved with most builds:
329     global
330         Compiler installation of rts, base, etc.
331     store
332         Nix-style local build cache
333     in-place
334         Project-specific build directory
336     By default, the package stack you will have with v2 commands is:
338     ::
340         -- [global, store]
342     So all remote packages required by your project will be
343     registered in the store package db (because it is last).
345     When cabal starts building your local projects, it appends the in-place db
346     to the end:
348     ::
350         -- [global, store, in-place]
352     So your local packages get put in ``dist-newstyle`` instead of the store.
354     This flag manipulates the default prefix: ``[global, store]`` and accepts
355     paths, the special value ``global`` referring to the global package db, and
356     ``clear`` which removes all prior entries. For example,
358     ::
360         -- [global, store, foo]
361         package-dbs: foo
363         -- [foo]
364         package-dbs: clear, foo
366         -- [bar, baz]
367         package-dbs: clear, foo, clear, bar, baz
369     The command line variant of this flag is ``--package-db=DB`` which can be
370     specified multiple times.
372 Phase control
373 -------------
375 The following settings apply to commands that result in build actions
376 (``build``, ``run``, ``repl``, ``test``...), and control which phases of the
377 build are executed.
379 .. option:: --dry-run
381     Do not download, build, or install anything, only print what would happen.
383 .. option:: --only-configure
385     Instead of performing a full build just run the configure step.
386     Only accepted by the ``build`` command.
388 .. option:: --only-download
390     Do not build anything, only fetch the packages.
392 .. option:: --only-dependencies
394     Install only the dependencies necessary to build the given packages.
395     Not accepted by the ``repl`` command.
397 Solver configuration options
398 ----------------------------
400 The following settings control the behavior of the dependency solver:
402 .. cfg-field:: constraints: constraints list (comma separated)
403                --constraint="pkg >= 2.0", -c "pkg >= 2.0"
404     :synopsis: Extra dependencies constraints.
406     Add extra constraints to the version bounds, flag settings,
407     and other properties a solver can pick for a
408     package. For example:
410     ::
412         constraints: bar == 2.1
414     A package can be specified multiple times in ``constraints``, in
415     which case the specified constraints are intersected. This is
416     useful, since the syntax does not allow you to specify multiple
417     constraints at once. For example, to specify both version bounds and
418     flag assignments, you would write:
420     ::
422         constraints: bar == 2.1,
423                      bar +foo -baz
425     Valid constraints take the same form as for the
426     :option:`runhaskell Setup.hs configure --constraint`
427     command line option.
429 .. cfg-field:: preferences: preference (comma separated)
430                --preference="pkg >= 2.0"
431     :synopsis: Preferred dependency versions.
433     Like :cfg-field:`constraints`, but the solver will attempt to satisfy
434     these preferences on a best-effort basis. The resulting install is locally
435     optimal with respect to preferences; specifically, no single package
436     could be replaced with a more preferred version that still satisfies
437     the hard constraints.
439     Operationally, preferences can cause the solver to attempt certain
440     version choices of a package before others, which can improve
441     dependency solver runtime.
443     One way to use :cfg-field:`preferences` is to take a known working set of
444     constraints (e.g., via ``cabal freeze``) and record them as
445     preferences. In this case, the solver will first attempt to use this
446     configuration, and if this violates hard constraints, it will try to
447     find the minimal number of upgrades to satisfy the hard constraints
448     again.
450     The command line variant of this field is
451     ``--preference="pkg >= 2.0"``; to specify multiple preferences, pass
452     the flag multiple times.
454 .. cfg-field:: allow-newer: none, all or list of scoped package names (space or comma separated)
455                --allow-newer, --allow-newer=[none,all,[scope:][^]pkg]
456     :synopsis: Lift dependencies upper bound constraints.
458     :default: ``none``
460     Allow the solver to pick more recent version of some packages than
461     would normally be permitted by the :pkg-field:`build-depends` bounds
462     of packages in the install plan. This option may be useful if the
463     dependency solver cannot otherwise find a valid install plan.
465     For example, to relax ``pkg``\ s :pkg-field:`build-depends` upper bound on
466     ``dep-pkg``, write a scoped package name of the form:
468     ::
470         allow-newer: pkg:dep-pkg
472     If the scope shall be limited to specific releases of ``pkg``, the
473     extended form as in
475     ::
477         allow-newer: pkg-1.2.3:dep-pkg, pkg-1.1.2:dep-pkg
479     can be used to limit the relaxation of dependencies on
480     ``dep-pkg`` by the ``pkg-1.2.3`` and ``pkg-1.1.2`` releases only.
482     The scoped syntax is recommended, as it is often only a single package
483     whose upper bound is misbehaving. In this case, the upper bounds of
484     other packages should still be respected; indeed, relaxing the bound
485     can break some packages which test the selected version of packages.
487     The syntax also allows to prefix the dependee package with a
488     modifier symbol to modify the scope/semantic of the relaxation
489     transformation in a additional ways. Currently only one modifier
490     symbol is defined, i.e. ``^`` (i.e. caret) which causes the
491     relaxation to be applied only to ``^>=`` operators and leave all other
492     version operators untouched.
494     However, in some situations (e.g., when attempting to build packages
495     on a new version of GHC), it is useful to disregard *all*
496     upper-bounds, with respect to a package or all packages. This can be
497     done by specifying just a package name, or using the keyword ``all``
498     to specify all packages:
500     ::
502         -- Disregard upper bounds involving the dependencies on
503         -- packages bar, baz. For quux only, relax
504         -- 'quux ^>= ...'-style constraints only.
505         allow-newer: bar, baz, ^quux
507         -- Disregard all upper bounds when dependency solving
508         allow-newer: all
510         -- Disregard all `^>=`-style upper bounds when dependency solving
511         allow-newer: ^all
514     For consistency, there is also the explicit wildcard scope syntax
515     ``*`` (or its alphabetic synonym ``all``). Consequently, the
516     examples above are equivalent to the explicitly scoped variants:
518     ::
520         allow-newer: all:bar, *:baz, *:^quux
522         allow-newer: *:*
523         allow-newer: all:all
525         allow-newer: *:^*
526         allow-newer: all:^all
528     In order to ignore all bounds specified by a package ``pkg-1.2.3``
529     you can combine scoping with a right-hand-side wildcard like so
531     ::
533         -- Disregard any upper bounds specified by pkg-1.2.3
534         allow-newer: pkg-1.2.3:*
536         -- Disregard only `^>=`-style upper bounds in pkg-1.2.3
537         allow-newer: pkg-1.2.3:^*
540     :cfg-field:`allow-newer` is often used in conjunction with a constraint
541     (in the :cfg-field:`constraints` field) forcing the usage of a specific,
542     newer version of a package.
544     The command line variant of this field is e.g. ``--allow-newer=bar``. A
545     bare ``--allow-newer`` is equivalent to ``--allow-newer=all``.
547 .. cfg-field:: allow-older: none, all, list of scoped package names (space or comma separated)
548                --allow-older, --allow-older=[none,all,[scope:][^]pkg]
549     :synopsis: Lift dependency lower bound constraints.
550     :since: 2.0
552     :default: ``none``
554     Like :cfg-field:`allow-newer`, but applied to lower bounds rather than
555     upper bounds.
557     The command line variant of this field is ``--allow-older=all``. A
558     bare ``--allow-older`` is equivalent to ``--allow-older=all``.
561 .. cfg-field:: index-state: HEAD, unix-timestamp, ISO8601 UTC timestamp.
562    :synopsis: Use source package index state as it existed at a previous time.
563    :since: 2.0
565    :default: ``HEAD``
567    This allows to change the source package index state the solver uses
568    to compute install-plans. This is particularly useful in
569    combination with freeze-files in order to also freeze the state the
570    package index was in at the time the install-plan was frozen.
572    ::
574       -- UNIX timestamp format example
575       index-state: @1474739268
577       -- ISO8601 UTC timestamp format example
578       -- This format is used by 'cabal configure'
579       -- for storing `--index-state` values.
580       index-state: 2016-09-24T17:47:48Z
582       -- Specify different index-states per package repository
583       -- Supported since 3.4
584       index-state:
585         , hackage.haskell.org 2020-05-06T22:33:27Z
586         , head.hackage 2020-04-29T04:11:05Z
588 .. cfg-field:: active-repositories: reponame1, reponame2
590     :synopsis: Specify active package repositories
591     :since: 3.4
593     :default: ``:rest``
595     Specifies which of the package repositories defined in the configuration
596     should be active. It's also useful for specifying the order and the way
597     active repositories are merged.
599     When searching for a certain version of a certain package name, the list of
600     active repositories is searched last-to-first.
602     For example, suppose hackage.haskell.org has versions 1.0 and 2.0 of
603     package X, and my-repository has version 2.0 of a similarly named package.
604     Then, with the following configuration:
606     ::
608       -- Force my-repository to be the first repository considered
609       active-repositories:
610         , hackage.haskell.org
611         , my-repository
613     version 2.0 of X will come from my-repository, and version 1.0 will come
614     from hackage.haskell.org.
616     If we want to make a repository the sole provider of certain packages, we
617     can put it last in the active repositories list, and add the :override
618     modifier.
620     For example, if we modify the previous example like this:
622     ::
624       active-repositories:
625         , hackage.haskell.org
626         , my-repository:override
628     then version 1.0 of package X won't be found in any case, because X is
629     present in my-repository only in version 2.0, and the :override forbids
630     searching for other versions of X further up the list.
632     :override has no effect for package names that aren't present in the
633     overriding repository.
635     The special repository reference :rest stands for "all the other repositories"
636     and can be useful to avoid lengthy lists of repository names:
638     ::
640       -- Force my-repository to be the first repository considered
641       active-repositories: :rest, my-repository
643     The special repository reference :none disables all repositories, effectively
644     putting cabal in "offline" mode:
646     ::
648       active-repositories: :none
651 .. cfg-field:: reject-unconstrained-dependencies: all, none
652                --reject-unconstrained-dependencies=[all|none]
653    :synopsis: Restrict the solver to packages that have constraints on them.
655    :default: none
656    :since: 2.6
658    By default, the dependency solver can include any package that it's
659    aware of in a build plan. If you wish to restrict the build plan to
660    a closed set of packages (e.g., from a freeze file), use this flag.
662    When set to `all`, all non-local packages that aren't goals must be
663    explicitly constrained. When set to `none`, the solver will
664    consider all packages.
667 Package configuration options
668 -----------------------------
670 Package options affect the building of specific packages. There are three
671 ways a package option can be specified:
673 -  They can be specified at the top-level, in which case they apply only
674    to **local package**, or
676 -  They can be specified inside a ``package`` stanza, in which case they
677    apply to the build of the package, whether or not it is local or
678    external.
680 -  They can be specified inside an ``package *`` stanza, in which case they
681    apply to all packages, local ones from the project and also external
682    dependencies.
685 For example, the following options specify that :cfg-field:`optimization`
686 should be turned off for all local packages, and that ``bytestring`` (possibly
687 an external dependency) should be built with ``-fno-state-hack``::
689     optimization: False
691     package bytestring
692         ghc-options: -fno-state-hack
694 ``ghc-options`` is not specifically described in this documentation, but is one
695 of many fields for configuring programs.  They take the form
696 ``progname-options`` and ``progname-location``, and can be set for all local
697 packages in a ``program-options`` stanza or under a package stanza.
699 On the command line, these options are applied to all local packages.
700 There is no per-package command line interface.
702 Some flags were added by more recent versions of the Cabal library. This
703 means that they are NOT supported by packages which use Custom setup
704 scripts that require a version of the Cabal library older than when the
705 feature was added.
707 .. cfg-field:: flags: list of +flagname or -flagname (space separated)
708                --flags="+foo -bar", -ffoo, -f-bar
709     :synopsis: Enable or disable package flags.
711     Force all flags specified as ``+flagname`` to be true, and all flags
712     specified as ``-flagname`` to be false. For example, to enable the
713     flag ``foo`` and disable ``bar``, set:
715     ::
717         flags: +foo -bar
719     Exactly one of + or - is required before each flag.
721     Flags are *per-package*, so it doesn't make much sense to specify
722     flags at the top-level, unless you happen to know that *all* of your
723     local packages support the same named flags. If a flag is not
724     supported by a package, it is ignored.
726     See also the solver configuration field :cfg-field:`constraints`.
728     The command line variant of this flag is ``--flags``. There is also
729     a shortened form ``-ffoo -f-bar``.
731     A common mistake is to say ``cabal build -fhans``, where
732     ``hans`` is a flag for a transitive dependency that is not in the
733     local package; in this case, the flag will be silently ignored. If
734     ``haskell-tor`` is the package you want this flag to apply to, try
735     ``--constraint="haskell-tor +hans"`` instead.
737 .. cfg-field:: with-compiler: executable
738                --with-compiler=executable
739     :synopsis: Path to compiler executable.
741     Specify the path to a particular compiler to be used. If not an
742     absolute path, it will be resolved according to the ``PATH``
743     environment. The type of the compiler (GHC, GHCJS, etc) must be
744     consistent with the setting of the :cfg-field:`compiler` field.
746     The most common use of this option is to specify a different version
747     of your compiler to be used; e.g., if you have ``ghc-7.8`` in your
748     path, you can specify ``with-compiler: ghc-7.8`` to use it.
750     This flag also sets the default value of :cfg-field:`with-hc-pkg`, using
751     the heuristic that it is named ``ghc-pkg-7.8`` (if your executable name
752     is suffixed with a version number), or is the executable named
753     ``ghc-pkg`` in the same directory as the ``ghc`` directory. If this
754     heuristic does not work, set :cfg-field:`with-hc-pkg` explicitly.
756     For inplace packages, ``cabal build`` maintains a separate build
757     directory for each version of GHC, so you can maintain multiple
758     build trees for different versions of GHC without clobbering each
759     other.
761     It's not possible to set :cfg-field:`with-compiler` on a
762     per-package basis.
764     The command line variant of this flag is
765     ``--with-compiler=ghc-7.8``; there is also a short version
766     ``-w ghc-7.8``.
768 .. cfg-field:: with-hc-pkg: executable
769                --with-hc-pkg=executable
770     :synopsis: Specifies package tool.
772     Specify the path to the package tool, e.g., ``ghc-pkg``. This
773     package tool must be compatible with the compiler specified by
774     :cfg-field:`with-compiler` (generally speaking, it should be precisely
775     the tool that was distributed with the compiler). If this option is
776     omitted, the default value is determined from :cfg-field:`with-compiler`.
778     The command line variant of this flag is
779     ``--with-hc-pkg=ghc-pkg-7.8``.
781 .. cfg-field:: optimization: nat
782                --enable-optimization
783                --disable-optimization
784     :synopsis: Build with optimization.
786     :default: ``1``
788     Build with optimization. This is appropriate for production use,
789     taking more time to build faster libraries and programs.
791     The optional *nat* value is the optimisation level. Some compilers
792     support multiple optimisation levels. The range is 0 to 2. Level 0
793     disables optimization, level 1 is the default. Level 2 is higher
794     optimisation if the compiler supports it. Level 2 is likely to lead
795     to longer compile times and bigger generated code. If you are not
796     planning to run code, turning off optimization will lead to better
797     build times and less code to be rebuilt when a module changes.
799     When optimizations are enabled, Cabal passes ``-O2`` to the C compiler.
801     We also accept ``True`` (equivalent to 1) and ``False`` (equivalent
802     to 0).
804     Note that as of GHC 8.0, GHC does not recompile when optimization
805     levels change (see :ghc-ticket:`10923`), so if
806     you change the optimization level for a local package you may need
807     to blow away your old build products in order to rebuild with the
808     new optimization level.
810     The command line variant of this flag is ``-O2`` (with ``-O1``
811     equivalent to ``-O``). There are also long-form variants
812     ``--enable-optimization`` and ``--disable-optimization``.
814 .. cfg-field:: configure-options: args (space separated)
815                --configure-option=arg
816     :synopsis: Options to pass to configure script.
818     A list of extra arguments to pass to the external ``./configure``
819     script, if one is used. This is only useful for packages which have
820     the ``Configure`` build type. See also the section on
821     :ref:`system-dependent parameters`.
823     The command line variant of this flag is ``--configure-option=arg``,
824     which can be specified multiple times to pass multiple options.
826 .. cfg-field:: compiler: ghc, ghcjs, jhc, lhc, uhc or haskell-suite
827                --compiler=compiler
828     :synopsis: Compiler to build with.
830     :default: ``ghc``
832     Specify the compiler toolchain to be used. This is independent of
833     ``with-compiler``, because the choice of toolchain affects Cabal's
834     build logic.
836     The command line variant of this flag is ``--compiler=ghc``.
838     It's not possible to set :cfg-field:`compiler` on a
839     per-package basis.
841 .. cfg-field:: tests: boolean
842                --enable-tests
843                --disable-tests
844     :synopsis: Build tests.
846     :default: ``False``
848     Force test suites to be enabled. For most users this should not be
849     needed, as we always attempt to solve for test suite dependencies,
850     even when this value is ``False``; furthermore, test suites are
851     automatically enabled if they are requested as a built target.
853     The command line variant of this flag is ``--enable-tests`` and
854     ``--disable-tests``.
856 .. cfg-field:: benchmarks: boolean
857                --enable-benchmarks
858                --disable-benchmarks
859     :synopsis: Build benchmarks.
861     :default: ``False``
863     Force benchmarks to be enabled. For most users this should not be
864     needed, as we always attempt to solve for benchmark dependencies,
865     even when this value is ``False``; furthermore, benchmarks are
866     automatically enabled if they are requested as a built target.
868     The command line variant of this flag is ``--enable-benchmarks`` and
869     ``--disable-benchmarks``.
871 .. cfg-field:: extra-prog-path: paths (newline or comma separated)
872                --extra-prog-path=PATH
873     :synopsis: Add directories to program search path.
874     :since: 1.18
876     A list of directories to search for extra required programs. Most
877     users should not need this, as programs like ``happy`` and ``alex``
878     will automatically be installed and added to the path. This can be
879     useful if a ``Custom`` setup script relies on an exotic extra
880     program.
882     The command line variant of this flag is ``--extra-prog-path=PATH``,
883     which can be specified multiple times.
885 .. cfg-field:: run-tests: boolean
886                --run-tests
887     :synopsis: Run package test suite upon installation.
889     :default: ``False``
891     Run the package test suite upon installation. This is useful for
892     saying "When this package is installed, check that the test suite
893     passes, terminating the rest of the build if it is broken."
895     .. warning::
897       One deficiency: the :cfg-field:`run-tests` setting of a package is NOT
898       recorded as part of the hash, so if you install something without
899       :cfg-field:`run-tests` and then turn on ``run-tests``, we won't
900       subsequently test the package. If this is causing you problems, give
901       us a shout.
903     The command line variant of this flag is ``--run-tests``.
905 Object code options
906 ^^^^^^^^^^^^^^^^^^^
908 .. cfg-field:: debug-info: integer
909                --enable-debug-info=<n>
910                --disable-debug-info
911     :synopsis: Build with debug info enabled.
912     :since: 1.22
914     :default: False
916     If the compiler (e.g., GHC 7.10 and later) supports outputting OS
917     native debug info (e.g., DWARF), setting ``debug-info: True`` will
918     instruct it to do so. See the GHC wiki page on :ghc-wiki:`DWARF`
919     for more information about this feature.
921     (This field also accepts numeric syntax, but until GHC 8.2 this didn't
922     do anything.)
924     The command line variant of this flag is ``--enable-debug-info`` and
925     ``--disable-debug-info``.
927 .. cfg-field:: split-sections: boolean
928                --enable-split-sections
929                --disable-split-sections
930     :synopsis: Use GHC's split sections feature.
931     :since: 2.2
933     :default: False
935     Use the GHC ``-split-sections`` feature when building the library. This
936     reduces the final size of the executables that use the library by
937     allowing them to link with only the bits that they use rather than
938     the entire library. The downside is that building the library takes
939     longer and uses a bit more memory.
941     This feature is supported by GHC 8.0 and later.
943     The command line variant of this flag is ``--enable-split-sections`` and
944     ``--disable-split-sections``.
946 .. cfg-field:: split-objs: boolean
947                --enable-split-objs
948                --disable-split-objs
949     :synopsis: Use GHC's split objects feature.
951     :default: False
953     Use the GHC ``-split-objs`` feature when building the library. This
954     reduces the final size of the executables that use the library by
955     allowing them to link with only the bits that they use rather than
956     the entire library. The downside is that building the library takes
957     longer and uses considerably more memory.
959     It is generally recommend that you use ``split-sections`` instead
960     of ``split-objs`` where possible.
962     The command line variant of this flag is ``--enable-split-objs`` and
963     ``--disable-split-objs``.
965 .. cfg-field:: executable-stripping: boolean
966                --enable-executable-stripping
967                --disable-executable-stripping
968     :synopsis: Strip installed programs.
970     :default: True
972     When installing binary executable programs, run the ``strip``
973     program on the binary. This can considerably reduce the size of the
974     executable binary file. It does this by removing debugging
975     information and symbols.
977     Not all Haskell implementations generate native binaries. For such
978     implementations this option has no effect.
980     If ``debug-info`` is set explicitly then ``executable-stripping`` is set
981     to ``False`` as otherwise all the debug symbols will be stripped.
983     The command line variant of this flag is
984     ``--enable-executable-stripping`` and
985     ``--disable-executable-stripping``.
987 .. cfg-field:: library-stripping: boolean
988                --enable-library-stripping
989                --disable-library-stripping
990     :synopsis: Strip installed libraries.
991     :since: 1.20
993     When installing binary libraries, run the ``strip`` program on the
994     binary, saving space on the file system. See also
995     ``executable-stripping``.
997     If ``debug-info`` is set explicitly then ``library-stripping`` is set
998     to ``False`` as otherwise all the debug symbols will be stripped.
1000     The command line variant of this flag is
1001     ``--enable-library-stripping`` and ``--disable-library-stripping``.
1003 Executable options
1004 ^^^^^^^^^^^^^^^^^^
1006 .. cfg-field:: program-prefix: prefix
1007                --program-prefix=prefix
1008     :synopsis: Prepend prefix to program names.
1010     :strike:`Prepend *prefix* to installed program names.` (Currently
1011     implemented in a silly and not useful way. If you need this to work
1012     give us a shout.)
1014     *prefix* may contain the following path variables: ``$pkgid``,
1015     ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
1016     ``$abitag``
1018     The command line variant of this flag is ``--program-prefix=foo-``.
1020 .. cfg-field:: program-suffix: suffix
1021                --program-suffix=suffix
1022     :synopsis: Append refix to program names.
1024     :strike:`Append *suffix* to installed program names.` (Currently
1025     implemented in a silly and not useful way. If you need this to work
1026     give us a shout.)
1028     The most obvious use for this is to append the program's version
1029     number to make it possible to install several versions of a program
1030     at once: ``program-suffix: $version``.
1032     *suffix* may contain the following path variables: ``$pkgid``,
1033     ``$pkg``, ``$version``, ``$compiler``, ``$os``, ``$arch``, ``$abi``,
1034     ``$abitag``
1036     The command line variant of this flag is
1037     ``--program-suffix='$version'``.
1039 Dynamic linking options
1040 ^^^^^^^^^^^^^^^^^^^^^^^
1042 .. cfg-field:: shared: boolean
1043                --enable-shared
1044                --disable-shared
1045     :synopsis: Build shared library.
1047     :default: False
1049     Build shared library. This implies a separate compiler run to
1050     generate position independent code as required on most platforms.
1052     The command line variant of this flag is ``--enable-shared`` and
1053     ``--disable-shared``.
1055 .. cfg-field:: executable-dynamic: boolean
1056                --enable-executable-dynamic
1057                --disable-executable-dynamic
1058     :synopsis: Link executables dynamically.
1060     :default: False
1062     Link executables dynamically. The executable's library dependencies
1063     should be built as shared objects. This implies ``shared: True``
1064     unless ``shared: False`` is explicitly specified.
1066     The command line variant of this flag is
1067     ``--enable-executable-dynamic`` and
1068     ``--disable-executable-dynamic``.
1070 .. cfg-field:: library-for-ghci: boolean
1071                --enable-library-for-ghci
1072                --disable-library-for-ghci
1073     :synopsis: Build libraries suitable for use with GHCi.
1075     :default: True
1077     Build libraries suitable for use with GHCi. This involves an extra
1078     linking step after the build.
1080     Not all platforms support GHCi and indeed on some platforms, trying
1081     to build GHCi libs fails. In such cases, consider setting
1082     ``library-for-ghci: False``.
1084     The command line variant of this flag is
1085     ``--enable-library-for-ghci`` and ``--disable-library-for-ghci``.
1087 .. cfg-field:: relocatable:
1088                --relocatable
1089     :synopsis: Build relocatable package.
1090     :since: 1.22
1092     :default: False
1094     :strike:`Build a package which is relocatable.` (TODO: It is not
1095     clear what this actually does, or if it works at all.)
1097     The command line variant of this flag is ``--relocatable``.
1099 Static linking options
1100 ^^^^^^^^^^^^^^^^^^^^^^
1102 .. cfg-field:: static: boolean
1103                --enable-static
1104                --disable-static
1105     :synopsis: Build static library.
1108     :default: False
1110     Roll this and all dependent libraries into a combined ``.a`` archive.
1111     This uses GHCs ``-staticlib`` flag, which is available for iOS and with
1112     GHC 8.4 and later for other platforms as well.
1114 .. cfg-field:: executable-static: boolean
1115                --enable-executable-static
1116                --disable-executable-static
1117     :synopsis: Build fully static executables.
1120     :default: False
1122     Build fully static executables.
1123     This links all dependent libraries into executables statically,
1124     including libc.
1125     This passes ``-static`` and ``-optl=-static`` to GHC.
1127 Foreign function interface options
1128 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1130 .. cfg-field:: extra-include-dirs: directories (comma or newline separated list)
1131                --extra-include-dirs=DIR
1132     :synopsis: Adds C header search path.
1134     An extra directory to search for C header files. You can use this
1135     flag multiple times to get a list of directories.
1137     You might need to use this flag if you have standard system header
1138     files in a non-standard location that is not mentioned in the
1139     package's ``.cabal`` file. Using this option has the same affect as
1140     appending the directory *dir* to the :pkg-field:`include-dirs` field in each
1141     library and executable in the package's ``.cabal`` file. The
1142     advantage of course is that you do not have to modify the package at
1143     all. These extra directories will be used while building the package
1144     and for libraries it is also saved in the package registration
1145     information and used when compiling modules that use the library.
1147     The command line variant of this flag is
1148     ``--extra-include-dirs=DIR``, which can be specified multiple times.
1150 .. cfg-field:: extra-lib-dirs: directories (comma or newline separated list)
1151                --extra-lib-dirs=DIR
1152     :synopsis: Adds library search directory.
1154     An extra directory to search for system libraries files.
1156     The command line variant of this flag is ``--extra-lib-dirs=DIR``,
1157     which can be specified multiple times.
1159 .. cfg-field:: extra-framework-dirs: directories (comma or newline separated list)
1160                --extra-framework-dirs=DIR
1161     :synopsis: Adds framework search directory (OS X only).
1163     An extra directory to search for frameworks (OS X only).
1165     You might need to use this flag if you have standard system
1166     libraries in a non-standard location that is not mentioned in the
1167     package's ``.cabal`` file. Using this option has the same affect as
1168     appending the directory *dir* to the :cfg-field:`extra-lib-dirs` field in
1169     each library and executable in the package's ``.cabal`` file. The
1170     advantage of course is that you do not have to modify the package at
1171     all. These extra directories will be used while building the package
1172     and for libraries it is also saved in the package registration
1173     information and used when compiling modules that use the library.
1175     The command line variant of this flag is
1176     ``--extra-framework-dirs=DIR``, which can be specified multiple
1177     times.
1179 Profiling options
1180 ^^^^^^^^^^^^^^^^^
1182 .. cfg-field:: profiling: boolean
1183                --enable-profiling
1184                --disable-profiling
1185     :synopsis: Enable profiling builds.
1186     :since: 1.22
1188     :default: False
1190     Build libraries and executables with profiling enabled (for
1191     compilers that support profiling as a separate mode). It is only
1192     necessary to specify :cfg-field:`profiling` for the specific package you
1193     want to profile; ``cabal build`` will ensure that all of its
1194     transitive dependencies are built with profiling enabled.
1196     To enable profiling for only libraries or executables, see
1197     :cfg-field:`library-profiling` and :cfg-field:`executable-profiling`.
1199     For useful profiling, it can be important to control precisely what
1200     cost centers are allocated; see :cfg-field:`profiling-detail`.
1202     The command line variant of this flag is ``--enable-profiling`` and
1203     ``--disable-profiling``.
1205 .. cfg-field:: profiling-detail: level
1206                --profiling-detail=level
1207     :synopsis: Profiling detail level.
1208     :since: 1.24
1210     Some compilers that support profiling, notably GHC, can allocate
1211     costs to different parts of the program and there are different
1212     levels of granularity or detail with which this can be done. In
1213     particular for GHC this concept is called "cost centers", and GHC
1214     can automatically add cost centers, and can do so in different ways.
1216     This flag covers both libraries and executables, but can be
1217     overridden by the ``library-profiling-detail`` field.
1219     Currently this setting is ignored for compilers other than GHC. The
1220     levels that cabal currently supports are:
1222     default
1223         For GHC this uses ``exported-functions`` for libraries and
1224         ``toplevel-functions`` for executables.
1225     none
1226         No costs will be assigned to any code within this component.
1227     exported-functions
1228         Costs will be assigned at the granularity of all top level
1229         functions exported from each module. In GHC, this
1230         is for non-inline functions.  Corresponds to ``-fprof-auto-exported``.
1231     toplevel-functions
1232         Costs will be assigned at the granularity of all top level
1233         functions in each module, whether they are exported from the
1234         module or not. In GHC specifically, this is for non-inline
1235         functions.  Corresponds to ``-fprof-auto-top``.
1236     all-functions
1237         Costs will be assigned at the granularity of all functions in
1238         each module, whether top level or local. In GHC specifically,
1239         this is for non-inline toplevel or where-bound functions or
1240         values.  Corresponds to ``-fprof-auto``.
1241     late-toplevel
1242         Like top-level but costs will be assigned to top level definitions after
1243         optimization. This lowers profiling overhead massively while giving similar
1244         levels of detail as toplevle-functions. However it means functions introduced
1245         by GHC during optimization will show up in profiles as well.
1246         Corresponds to ``-fprof-late`` if supported and ``-fprof-auto-top`` otherwise.
1247     late
1248         Currently an alias for late-toplevel
1250     The command line variant of this flag is
1251     ``--profiling-detail=none``.
1253 .. cfg-field:: library-profiling-detail: level
1254                --library-profiling-detail=level
1255     :synopsis: Libraries profiling detail level.
1256     :since: 1.24
1258     Like :cfg-field:`profiling-detail`, but applied only to libraries
1260     The command line variant of this flag is
1261     ``--library-profiling-detail=none``.
1263 .. cfg-field:: library-vanilla: boolean
1264                --enable-library-vanilla
1265                --disable-library-vanilla
1266     :synopsis: Build libraries without profiling.
1268     :default: True
1270     Build ordinary libraries (as opposed to profiling libraries).
1271     Mostly, you can set this to False to avoid building ordinary
1272     libraries when you are profiling.
1274     The command line variant of this flag is
1275     ``--enable-library-vanilla`` and ``--disable-library-vanilla``.
1277 .. cfg-field:: library-profiling: boolean
1278                --enable-library-profiling
1279                --disable-library-profiling
1280     :synopsis: Build libraries with profiling enabled.
1281     :since: 1.22
1283     :default: False
1285     Build libraries with profiling enabled.  You probably want
1286     to use :cfg-field:`profiling` instead.
1288     The command line variant of this flag is
1289     ``--enable-library-profiling`` and ``--disable-library-profiling``.
1291 .. cfg-field:: executable-profiling: boolean
1292                --enable-executable-profiling
1293                --disable-executable-profiling
1294     :synopsis: Build executables with profiling enabled.
1295     :since: 1.22
1297     :default: False
1299     Build executables with profiling enabled. You probably want
1300     to use :cfg-field:`profiling` instead.
1302     The command line variant of this flag is
1303     ``--enable-executable-profiling`` and
1304     ``--disable-executable-profiling``.
1306 Coverage options
1307 ^^^^^^^^^^^^^^^^
1309 .. cfg-field:: coverage: boolean
1310                --enable-coverage
1311                --disable-coverage
1312     :synopsis: Build with coverage enabled.
1313     :since: 1.22
1315     :default: False
1317     Build libraries and executables (including test suites) with Haskell
1318     Program Coverage enabled. Running the test suites will automatically
1319     generate coverage reports with HPC.
1321     The command line variant of this flag is ``--enable-coverage`` and
1322     ``--disable-coverage``.
1324 .. cfg-field:: library-coverage: boolean
1325                --enable-library-coverage
1326                --disable-library-coverage
1327     :since: 1.22
1328     :deprecated:
1330     :default: False
1332     Deprecated, use :cfg-field:`coverage`.
1334     The command line variant of this flag is
1335     ``--enable-library-coverage`` and ``--disable-library-coverage``.
1337 Haddock options
1338 ^^^^^^^^^^^^^^^
1340 .. cfg-field:: documentation: boolean
1341                --enable-documentation
1342                --disable-documentation
1343     :synopsis: Enable building of documentation.
1345     :default: False
1347     Enables building of Haddock documentation.
1348     Implied when calling ``cabal haddock``.
1350     The command line variant of this flag is ``--enable-documentation``
1351     and ``--disable-documentation``.
1353     ``documentation: true`` does not imply
1354     :cfg-field:`haddock-all`,
1355     :cfg-field:`haddock-benchmarks`,
1356     :cfg-field:`haddock-executables`,
1357     :cfg-field:`haddock-internal` or
1358     :cfg-field:`haddock-tests`.
1359     These need to be enabled separately if desired.
1361 .. cfg-field:: doc-index-file: templated path
1362                --doc-index-file=TEMPLATE
1363     :synopsis: Path to haddock templates.
1365     A central index of Haddock API documentation (template cannot use
1366     ``$pkgid``), which should be updated as documentation is built.
1368 The following commands are equivalent to ones that would be passed when
1369 running ``setup haddock``.
1371 .. cfg-field:: haddock-hoogle: boolean
1372                --haddock-hoogle
1373     :synopsis: Generate Hoogle file.
1375     :default: False
1377     Generate a text file which can be converted by Hoogle_
1378     into a database for searching.
1379     This is equivalent to running ``haddock`` with the ``--hoogle`` flag.
1381 .. cfg-field:: haddock-html: boolean
1382                --haddock-html
1383     :synopsis: Build HTML documentation.
1385     :default: True
1387     Build HTML documentation.
1389 .. cfg-field:: haddock-quickjump: boolean
1390                --haddock-quickjump
1391     :synopsis: Generate Quickjump file.
1393     :default: False
1395     Generate an index for interactive documentation navigation.
1396     This is equivalent to running ``haddock`` with the ``--quickjump`` flag.
1398 .. cfg-field:: haddock-html-location: templated path
1399                --haddock-html-location=TEMPLATE
1400     :synopsis: Haddock HTML templates location.
1402     Specify a template for the location of HTML documentation for
1403     prerequisite packages. The substitutions are applied to the template
1404     to obtain a location for each package, which will be used by
1405     hyperlinks in the generated documentation. For example, the
1406     following command generates links pointing at Hackage pages:
1408     ::
1410         html-location: http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html
1412     If passed on the command line,
1413     the argument may be quoted to prevent substitution by the shell.
1415     ::
1417         --html-location='http://hackage.haskell.org/packages/archive/$pkg/latest/doc/html'
1419     If this option is omitted, the location for each package is obtained
1420     using the package tool (e.g. ``ghc-pkg``).
1422 .. cfg-field:: haddock-executables: boolean
1423                --haddock-executables
1424     :synopsis: Generate documentation for executables.
1426     :default: False
1428     Run haddock on all executable programs.
1430 .. cfg-field:: haddock-tests: boolean
1431                --haddock-tests
1432     :synopsis: Generate documentation for tests.
1434     :default: False
1436     Run haddock on all test suites.
1438 .. cfg-field:: haddock-benchmarks: boolean
1439                --haddock-benchmarks
1440     :synopsis: Generate documentation for benchmarks.
1442     :default: False
1444     Run haddock on all benchmarks.
1446 .. cfg-field:: haddock-internal: boolean
1447                --haddock-internal
1448     :synopsis: Generate documentation for internal modules
1450     :default: False
1452     Build haddock documentation which includes unexposed modules and
1453     symbols.
1455 .. cfg-field:: haddock-all: boolean
1456                --haddock-all
1457     :synopsis: Generate documentation for everything
1459     :default: False
1461     Run haddock on all components.
1463 .. cfg-field:: haddock-css: path
1464                --haddock-css=PATH
1465     :synopsis: Location of Haddock CSS file.
1467     The CSS file that should be used to style the generated
1468     documentation (overriding haddock's default).
1470 .. cfg-field:: haddock-hyperlink-source: boolean
1471                --haddock-hyperlink-source
1472     :synopsis: Generate hyperlinked source code for documentation
1474     :default: False
1476     Generated hyperlinked source code using `HsColour`_, and have
1477     Haddock documentation link to it.
1478     This is equivalent to running ``haddock`` with the ``--hyperlinked-source`` flag.
1480 .. cfg-field:: haddock-hscolour-css: path
1481                --haddock-hscolour-css=PATH
1482     :synopsis: Location of CSS file for HsColour
1484     The CSS file that should be used to style the generated hyperlinked
1485     source code (from `HsColour`_).
1487 .. cfg-field:: haddock-contents-location: URL
1488                --haddock-contents-location=URL
1489     :synopsis: URL for contents page.
1491     A baked-in URL to be used as the location for the contents page.
1493 .. cfg-field:: haddock-keep-temp-files: boolean
1494     :synopsis: Keep temporary Haddock files.
1496     Keep temporary files.
1498     There is no command line variant of this flag.
1500 .. cfg-field:: open: boolean
1501                --open
1502     :synopsis: Open generated documentation in-browser.
1504     When generating HTML documentation, attempt to open it in a browser
1505     when complete. This will use ``xdg-open`` on Linux and BSD systems,
1506     ``open`` on macOS, and ``start`` on Windows.
1508 Advanced global configuration options
1509 -------------------------------------
1511 .. cfg-field:: write-ghc-environment-files: always, never, or ghc8.4.4+
1512                --write-ghc-environment-files=policy
1513     :synopsis: Whether a ``.ghc.environment`` should be created after a successful build.
1515     :default: ``never``
1517     Whether a `GHC package environment file <https://downloads.haskell.org/~ghc/master/users-guide/packages.html#package-environments>`_
1518     should be created after a successful build.
1520     Since Cabal 3.0, defaults to ``never``. Before that, defaulted to
1521     creating them only when compiling with GHC 8.4.4 and older (GHC
1522     8.4.4 `is the first version
1523     <https://gitlab.haskell.org/ghc/ghc/-/issues/13753>`_ that supports
1524     the ``-package-env -`` option that allows ignoring the package
1525     environment files).
1527 .. cfg-field:: build-info: True, False
1528                --enable-build-info
1529                --disable-build-info
1530     :synopsis: Whether build information for each individual component should be
1531                written in a machine readable format.
1533     :default: ``False``
1535     Enable generation of build information for Cabal components. Contains very
1536     detailed information on how to build an individual component, such as
1537     compiler version, modules of a component and how to compile the component.
1539     The output format is in json, and the exact location can be discovered from
1540     ``plan.json``, where it is identified by ``build-info`` within the items in
1541     the ``install-plan``.
1542     Note, that this field in ``plan.json`` can be ``null``, if and only if
1543     ``build-type: Custom`` is set, and the ``Cabal`` version is too
1544     old (i.e. ``< 3.7``).
1545     If the field is missing entirely, the component is not a local one, thus,
1546     no ``build-info`` exists for that particular component within the
1547     ``install-plan``.
1549     .. note::
1550         The format and fields of the generated build information is currently experimental,
1551         in the future we might add or remove fields, depending on the needs of other tooling.
1554 .. cfg-field:: http-transport: curl, wget, powershell, or plain-http
1555                --http-transport=transport
1556     :synopsis: Transport to use with http(s) requests.
1558     :default: ``curl``
1560     Set a transport to be used when making http(s) requests.
1562     The command line variant of this field is ``--http-transport=curl``.
1564 .. cfg-field:: ignore-expiry: boolean
1565                --ignore-expiry
1566     :synopsis: Ignore Hackage expiration dates.
1568     :default: False
1570     If ``True``, we will ignore expiry dates on metadata from Hackage.
1572     In general, you should not set this to ``True`` as it will leave you
1573     vulnerable to stale cache attacks. However, it may be temporarily
1574     useful if the main Hackage server is down, and we need to rely on
1575     mirrors which have not been updated for longer than the expiry
1576     period on the timestamp.
1578     The command line variant of this field is ``--ignore-expiry``.
1580 .. cfg-field:: remote-repo-cache: directory
1581                --remote-repo-cache=DIR
1582     :synopsis: Location of packages cache.
1584     :default: ``~/.cabal/packages``
1586     :strike:`The location where packages downloaded from remote
1587     repositories will be cached.` Not implemented yet.
1589     The command line variant of this flag is
1590     ``--remote-repo-cache=DIR``.
1592 .. cfg-field:: logs-dir: directory
1593                --logs-dir=DIR
1594     :synopsis: Directory to store build logs.
1596     :default: ``~/.cabal/logs``
1598     :strike:`The location where build logs for packages are stored.`
1599     Not implemented yet.
1601     The command line variant of this flag is ``--logs-dir=DIR``.
1603 .. cfg-field:: build-summary: template filepath
1604                --build-summary=TEMPLATE
1605     :synopsis: Build summaries location.
1607     :default: ``~/.cabal/logs/build.log``
1609     :strike:`The file to save build summaries.` Not implemented yet.
1611     Valid variables which can be used in the path are ``$pkgid``,
1612     ``$compiler``, ``$os`` and ``$arch``.
1614     The command line variant of this flag is
1615     ``--build-summary=TEMPLATE``.
1617 Undocumented fields: ``root-cmd``, ``symlink-bindir``, ``build-log``,
1618 ``remote-build-reporting``, ``report-planned-failure``, ``offline``.
1620 Advanced solver options
1621 ^^^^^^^^^^^^^^^^^^^^^^^
1623 Most users generally won't need these.
1625 .. cfg-field:: solver: modular
1626                --solver=modular
1627     :synopsis: Which solver to use.
1629     This field is reserved to allow the specification of alternative
1630     dependency solvers. At the moment, the only accepted option is
1631     ``modular``.
1633     The command line variant of this field is ``--solver=modular``.
1635 .. cfg-field:: max-backjumps: nat
1636                --max-backjumps=N
1637     :synopsis: Maximum number of solver backjumps.
1639     :default: 4000
1641     Maximum number of backjumps (backtracking multiple steps) allowed
1642     while solving. Set -1 to allow unlimited backtracking, and 0 to
1643     disable backtracking completely.
1645     The command line variant of this field is ``--max-backjumps=4000``.
1647 .. cfg-field:: reorder-goals: boolean
1648                --reorder-goals
1649                --no-reorder-goals
1650     :synopsis: Allow solver to reorder goals.
1652     :default: False
1654     When enabled, the solver will reorder goals according to certain
1655     heuristics. Slows things down on average, but may make backtracking
1656     faster for some packages. It's unlikely to help for small projects,
1657     but for big install plans it may help you find a plan when otherwise
1658     this is not possible. See :issue:`1780` for more commentary.
1660     The command line variant of this field is ``--(no-)reorder-goals``.
1662 .. cfg-field:: count-conflicts: boolean
1663                --count-conflicts
1664                --no-count-conflicts
1665     :synopsis: Solver prefers versions with less conflicts.
1667     :default: True
1669     Try to speed up solving by preferring goals that are involved in a
1670     lot of conflicts.
1672     The command line variant of this field is
1673     ``--(no-)count-conflicts``.
1675 .. cfg-field:: fine-grained-conflicts: boolean
1676                --fine-grained-conflicts
1677                --no-fine-grained-conflicts
1678     :synopsis: Skip a version of a package if it does not resolve any conflicts
1679                encountered in the last version (solver optimization).
1681     :default: True
1683     When enabled, the solver will skip a version of a package if it does not
1684     resolve any of the conflicts encountered in the last version of that
1685     package. For example, if ``foo-1.2`` depended on ``bar``, and the solver
1686     couldn't find consistent versions for ``bar``'s dependencies, then the
1687     solver would skip ``foo-1.1`` if it also depended on ``bar``.
1689     The command line variant of this field is
1690     ``--(no-)fine-grained-conflicts``.
1692 .. cfg-field:: minimize-conflict-set: boolean
1693                --minimize-conflict-set
1694                --no-minimize-conflict-set
1695     :synopsis: Try to improve the solver error message when there is no
1696                solution.
1698     :default: False
1700     When there is no solution, try to improve the solver error message
1701     by finding a minimal conflict set. This option may increase run
1702     time significantly, so it is off by default.
1704     The command line variant of this field is
1705     ``--(no-)minimize-conflict-set``.
1707 .. cfg-field:: strong-flags: boolean
1708                --strong-flags
1709                --no-strong-flags
1710     :synopsis: Do not defer flag choices when solving.
1712     :default: False
1714     Do not defer flag choices. (TODO: Better documentation.)
1716     The command line variant of this field is ``--(no-)strong-flags``.
1718 .. cfg-field:: allow-boot-library-installs: boolean
1719                --allow-boot-library-installs
1720                --no-allow-boot-library-installs
1721     :synopsis: Allow cabal to install or upgrade any package.
1723     :default: False
1725     By default, the dependency solver doesn't allow ``base``,
1726     ``ghc-prim``, ``integer-simple``, ``integer-gmp``, and
1727     ``template-haskell`` to be installed or upgraded. This flag
1728     removes the restriction.
1730     The command line variant of this field is
1731     ``--(no-)allow-boot-library-installs``.
1733 .. cfg-field:: cabal-lib-version: version
1734                --cabal-lib-version=version
1735     :synopsis: Version of Cabal library used to build package.
1737     This field selects the version of the Cabal library which should be
1738     used to build packages. This option is intended primarily for
1739     internal development use (e.g., forcing a package to build with a
1740     newer version of Cabal, to test a new version of Cabal.) (TODO:
1741     Specify its semantics more clearly.)
1743     The command line variant of this field is
1744     ``--cabal-lib-version=1.24.0.1``.
1746 .. cfg-field:: prefer-oldest: boolean
1747                --prefer-oldest
1748                --no-prefer-oldest
1749     :synopsis: Prefer the oldest versions of packages available.
1750     :since:    3.8
1752     :default:  False
1754     By default, when solver has a choice of multiple versions of the same
1755     package, it will first try to derive a build plan with the latest
1756     version. This flag switches the behaviour, making the solver
1757     to prefer the oldest packages available.
1759     The primary use case is to help users in establishing lower bounds
1760     of upstream dependencies.
1762     The command line variant of this field is ``--(no-)prefer-oldest``.
1764 .. include:: references.inc