cabal-constraints: Repeatable builds for cabalized Haskell projects.

[ development, distribution, mit, program ] [ Propose Tags ]

Repeatable builds for cabalized Haskell projects

'cabal-constraints' provides repeatable builds for cabalized Haskell projects by "freezing" the exact versions of the dependencies selected by 'cabal-install'. All build environments for the project, such as the test or staging build environments, or other developers collaborating on the project, will then use the same dependency versions.

It is designed to be used alongside 'cabal-install' sandboxes, in which case isolated, repeatable builds can be achieved.

Using cabal-constraints

'cabal-constraints' should be run from the root directory of a cabalized Haskell project and given the path to the `setup-config` file to use. It will print out all dependencies of the project in a format suitable for use in a `cabal-install` config file. For example, running 'cabal-constraints' against itself produces the following:

$ cabal-constraints dist/dist-sandbox-500003c6/setup-config
constraints: Cabal == 1.19.0
, array ==
, base ==
, bytestring ==
, containers ==
, deepseq ==
, directory ==
, filepath ==
, ghc-prim ==
, integer-gmp ==
, old-locale ==
, pretty ==
, process ==
, rts == 1.0
, time ==
, unix ==

A single mandatory argument must be provided which is the path to the setup-config file to use. The file will be located under the dist directory. Usually there will be a single setup-config file which can be found by running find dist -name setup-config from the root directory of the project. If your project has more than one such file, it is likely because you have built it either with and without sandboxes or with multiple sandboxes. You probably want the most recently modified file which can be found with ls -tr $( find dist -name setup-config ) | tail -n1.

To use these constraints for reproducible builds, one should make use of the new sandbox feature of cabal-install 1.18. The constraints can be redirected to cabal.config and committed to your code repository. When the project is built, the same set of dependency versions will be resolved by cabal-install ensuring repeatable builds.

If cabal.config contains no other information the simplest solution is to overwrite it:

$ cabal-constraints > cabal.config

If cabal.config contains information that needs to be preserved, the following will replace the constraints section and everything following it with the new constraints. If you ensure that the constraints section is the last section of the file, all other information in it will be kept.

$ sed -i /^constraints:/,$d cabal.config && cabal-constraints >> cabal.config


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS]
Dependencies base (>=4.6 && <4.7), Cabal (>=1.18), optparse-applicative (>= [details]
License MIT
Author Ben Armston
Category Development, Distribution
Home page
Source repo head: git clone
Uploaded by BenArmston at 2013-12-08T22:03:44Z
Distributions NixOS:
Reverse Dependencies 1 direct, 0 indirect [details]
Executables cabal-constraints
Downloads 1350 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-12-19 [all 6 reports]