MyNixOS website logo
Description

Repeatable builds for cabalized Haskell projects.

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 == 0.4.0.1
, base == 4.6.0.1
, bytestring == 0.10.0.2
, containers == 0.5.0.0
, deepseq == 1.3.0.1
, directory == 1.2.0.1
, filepath == 1.3.0.1
, ghc-prim == 0.3.0.0
, integer-gmp == 0.5.0.0
, old-locale == 1.0.0.5
, pretty == 1.1.1.0
, process == 1.1.0.2
, rts == 1.0
, time == 1.4.0.1
, unix == 2.6.0.1

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
Metadata

Version

0.0.0.1

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows