Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

62.7. cabal-install-3.18.1.0

The cabal command — builds and installs Haskell packages

Version 3.18.1.0, release 1
Shelf lang — Language implementations, plus the modules of any language that has no module shelf of its own
Phase 31_compilers (Compilers), 21 of 22 in build order
Licence BSD-3-Clause
Homepage https://www.haskell.org/cabal/
Build time 11.3 SBU
Installed size 37.5 MiB in 24 files
Recipe ports/core/lang/cabal-install/kpkgbuild

About

cabal-install provides cabal, the command that solves, builds and installs Haskell packages. In KDOS it is the build tool of the Haskell ports that come after it, pandoc and shellcheck, which their recipes run as cabal v2-install against a local repository made from their vendor bundles (see The Haskell bundle).

cabal-install is itself a Haskell program with Hackage dependencies, and there is no cabal to build it with before it exists. The recipe uses upstream’s bootstrap/bootstrap.py, which builds each dependency and then cabal-install with each package’s Setup.hs and the installed ghc alone. The dependencies are the port’s vendor bundle, the second sha256 = line, laid out in _build/tarballs where the script looks for a prefetched set: <pkg>-<ver>.tar.gz and the revised <pkg>.cabal beside it. The script checks every file against the plan’s hashes before it builds anything, and downloads only a file that is not there. The chroot has no network, so a missing file stops the build as an altered one does.

Sources

Dependencies

Depends on: ghc, zlib, pkgconf, python3.

Required by (2): pandoc, shellcheck.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/31_compilers/phase.env && kpkg install cabal-install'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/cabal-install.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/lang/cabal-install
echo 'c3d51e23a7e10cc9c13c59320267f831732d281ba3fc7897423e0b83b8221a41  cabal-install-3.18.1.0.tar.gz' | sha256sum -c -
echo 'f120fdae0a3db5af26647e36357c70228c38cc1d01cf8a9ef4a1b38aa6371794  cabal-install-vendor-3.18.1.0.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/cabal-install
SRC=$SRC_ROOT/cabal-install-3.18.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf cabal-install-3.18.1.0.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _ghc, hsplan and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

tar xf "$PORT_SRC/$name-vendor-$version.tar.xz" -C "$SRC_ROOT"
mkdir -p _build/tarballs
for f in "$SRC_ROOT"/vendor/*.tar.gz; do
	cp "$f" _build/tarballs/
done
for f in "$SRC_ROOT"/vendor/*.cabal; do
	b=${f##*/}
	cp "$f" "_build/tarballs/${b%-*}.cabal"
done
python3 bootstrap/bootstrap.py -w /usr/bin/ghc -d "$hsplan" --no-archive

install -Dm755 _build/bin/cabal "$PKG/usr/bin/cabal"
install -d "$PKG/usr/share/man/man1"
_build/bin/cabal man --raw > "$PKG/usr/share/man/man1/cabal.1"
install -Dm644 cabal-install/bash-completion/cabal \
	"$PKG/usr/share/bash-completion/completions/cabal"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/cabal-install, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf cabal-install-3.18.1.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/cabal-install, and runs the triggers its paths call for.

Contents

Installed programs: cabal.

Installed directories: /usr/share/licenses/cabal-install.

Short descriptions

cabal a system for building and packaging Haskell libraries and programs

Notes

The plan is solved against one exact GHC: bootstrap.py takes each package the plan marks as coming with GHC from the installed compiler’s package database, at exactly the version the plan names, and stops when GHC has another. The recipe’s _ghc helper, which picks the plan, therefore moves with the ghc port: a GHC bump with no matching bootstrap/linux-<version>.json in the cabal source cannot build this port, and the vendor bundle is generated again from the new plan.

The manual page is not in the source; it is generated by the built program itself, with cabal man --raw, during the install. The bash completion file comes from the source tree.