No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This project is no longer maintained. Please have a look at using the Nix package manager which handles things in a much better way here.


cabal2pkgbuild is a script used to generate proper PKGBUILD files from any .cabal file from Hackage, with the help of cblrepo (which is currently used to maintain Haskell packages on Arch Linux).


This script is available on the AUR.


These are the following dependencies on Arch Linux:

  • cblrepo
  • coreutils
  • grep
  • pacman
  • sed
  • zsh


Create an empty folder, e.g., my-haskell-packages.

Patch Folder

You must have an empty folder named patch within this folder (i.e., my-haskell-packages/patch. This folder will be accessed by cblrepo to generate the proper PKGBUILD; you can have 3 kinds of patches:

  • <hackage_package_name>.cabal
  • <hackage_package_name>.pkgbuild
  • <hackage_package_name>.source

Essentially, the idea is to patch any misbehaving Hackage packages so that a proper, working Arch Linux package can be generated. Refer to the cblrepo documentation for further explanation.

Database Generation, PKGBUILD Creation, and Package Installation

Go into my-haskell-packages, and create a file listing all Hackage packages, one on each line, that you'd like to create PKGBUIKLDs for. Optionally you can specify an explicit version through comma (','). So format of each line is <package-name>[,<package-version>]. This is called the <hackage_packages_file> file by convention.

The following is a sample <hackage_pacakges_file> file:


The names of the packages are taken directly from the Hackage site (i.e., the case-sensitivity matches the original names on Hackage). As the packages here are added in order, you should put them so that the dependencies are built first. The lens package, for example, has a ton of dependencies and all of these are listed before lens itself. It takes some trial and error to get this right (the makepkg mode will output failures as pacman fails to find the necessary dependencies), but it should not be too difficult.

We now run the script 3 times:

/path/to/ <hackage_packages_file> initdb-sync
/path/to/ <hackage_packages_file> pkgbuild
/path/to/ <hackage_packages_file> makepkg

The initdb-sync mode initializes the cblrepo database, populating it with all of the system Haskell packages already installed on your computer.[^symlink] More importantly, it lets cblrepo know which version numbers are the latest ones posted on Hackage. It then adds the listed packages in <hackage_packages_file>. It does this by creating a cache folder first; if the corresponding cabal files from <hackage_packages_file> already exist, they are not downloaded. The user is responsible for keeping track of the state of cache, although as cabal files are saved with the version number in the file name, there is no danger of somehow overwriting wrong versions through this script.

If you want to skip the sync with Hackage (e.g., on subsequent immediate runs of this script), use initdb instead of initdb-sync.

The pkgbuild mode removes all haskell-* folders in the current folder, before populating the current directory with all the Hackage packages' generated PKGBUILD folders.

Finally, the makepkg mode goes through each package and runs makepkg -sif for that package. This mode is a convenience mode: you can manually go into each generated PKGBUILD directory and do the usual makepkg -sf/pacman -U combo yourself --- however, it is probably easier with this mode because you retain the dependency ordering information (the order of the packages in <hackage_packages_file>). That is, if you manually built the packages yourself, you'd have to remember which packages to build first.

[^symlink]: NOTE: cabal2pkgbuild's initdb and initdb-sync modes will OVERWRITE the file in ~/.cblrepo/cblrepo.db with the one generated by it with a symlink.