arch-hs: A program generating PKGBUILD for hackage packages.

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

arch-hs is a command-line program, which simplifies the process of producing and maintaining haskell packages for archlinux distribution by automating the PKGBUILD generation with the dependency resolving and template filling. Packagers should follow the Haskell package guidelines.

[Skip to Readme]


Maintainer's Corner

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,,,,,,
Change log
Dependencies aeson (>=1.5.4 && <1.6), algebraic-graphs (>=0.5 && <0.6), arch-hs, base (>=4.14.0 && <4.15), bytestring (>=0.10.10 && <0.11), Cabal (>=3.2.0 && <3.3), colourista (>=0.1 && <0.2), conduit (>=1.3.2 && <1.4), conduit-extra (>=1.3.5 && <1.4), containers (>=0.6.2 && <0.7), deepseq (>=1.4.4 && <1.5), directory (>=1.3.6 && <1.4), filepath (>=1.4.2 && <1.5), hackage-db (>=2.1.0 && <2.2), megaparsec (>=8.0.0 && <8.1), microlens (>=0.4.11 && <0.5), microlens-th (>=0.4.3 && <0.5), neat-interpolation (>=0.5.1 && <0.6), optparse-applicative (>=0.15.1 && <0.16), polysemy (>=1.3.0 && <1.4), process, req (>=3.6.0 && <3.7), split (>=0.2.3 && <0.3), tar-conduit (>=0.3.2 && <0.4), template-haskell (>=2.16.0 && <2.17), text (>=1.2.3 && <1.3) [details]
License MIT
Copyright 2020 berberman
Author berberman
Maintainer berberman <>
Category Distribution
Home page
Bug tracker
Source repo head: git clone
Uploaded by berberman at 2020-09-19T02:18:21Z
Distributions Arch:, NixOS:
Executables arch-hs-uusi, arch-hs-diff, arch-hs
Downloads 2735 total (26 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2020-09-19 [all 2 reports]

Readme for arch-hs-

[back to package description]


GitHub CI Build Status Hackage MIT license

A program generating PKGBUILD for hackage packages. Special thanks to felixonmars.

Notice that arch-hs will always support only the latest GHC version.


Given the name of a package in hackage, arch-hs can generate its corresponding PKGBUILD draft. It has a naive built-in dependency solver, which can fetch all dependencies we need to produce a archlinux package. During the dependency calculation, all version constraints will be discarded due to the arch haskell packaging strategy, and packages already exist in the community will be excluded.


arch-hs is just a PKGBUILD text file generator, which is not integrated with pacman, depending on nothing than:

  • Pacman database (community.db), i.e., archlinux system. the db file can be specified manually for now.

  • Hackage database tarball (01-index.tar, or 00-index.tar previously), usually provided by cabal-install.


Install the latest release

# pacman -S arch-hs

Install it directly using pacman.

Install the development version

$ yay -S arch-hs-git

Install it using your AUR helper, or just pacman with archlinxcn, which provides pre-built binary, following the latest git commit.

Build from source (for development)

$ git clone

Then build and install it via stack or cabal.


$ stack install

Cabal (dynamic)

$ cabal configure --disable-library-vanilla --enable-shared --enable-executable-dynamic --ghc-options=-dynamic 
$ cabal install


Just run arch-hs in command line with options and a target. Here is an example: we will create the archlinux package of dhall-lsp-server:

$ arch-hs -o "/home/berberman/Desktop/test/" dhall-lsp-server


  ⓘ Recommended package order (from topological sort):
1. haskell-lsp-types
2. haskell-lsp
3. dhall-lsp-server

  ⓘ Detected flags from targets (their values will keep default unless you specify):
    ⚐ demo:
      description: Build the lsp-hello demo executable
      default: False
      isManual: False

  ⓘ Write file: /home/berberman/Desktop/test/dhall-lsp-server/PKGBUILD
  ⓘ Write file: /home/berberman/Desktop/test/haskell-lsp/PKGBUILD
  ⓘ Write file: /home/berberman/Desktop/test/haskell-lsp-types/PKGBUILD
  ✔ Success!

This message tells that in order to package dhall-lsp-server, we must package haskell-lsp-types and haskell-lsp sequentially, because they don't present in archlinux community repo.

├── dhall-lsp-server
│   └── PKGBUILD
├── haskell-lsp
│   └── PKGBUILD
└── haskell-lsp-types
    └── PKGBUILD

arch-hs will generate PKGBUILD for each packages. Let's see what we have in ./haskell-lsp/PKGBUILD:

# This file was generated by arch-hs, please check it manually.
# Maintainer: Your Name <>

pkgdesc="Haskell library for the Microsoft Language Server Protocol"
depends=('ghc-libs' 'haskell-aeson' 'haskell-async' 'haskell-attoparsec' 'haskell-data-default' 'haskell-hashable' 'haskell-lsp-types' 'haskell-hslogger' 'haskell-lens' 'haskell-network-uri' 'haskell-rope-utf16-splay' 'haskell-sorted-list' 'haskell-temporary' 'haskell-unordered-containers' 'haskell-vector')
makedepends=('ghc' 'haskell-quickcheck' 'haskell-hspec' 'haskell-hspec-discover' 'haskell-quickcheck-instances')

  cd $_hkgname-$pkgver

build() {
  cd $_hkgname-$pkgver    

  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
    --prefix=/usr --docdir=/usr/share/doc/$pkgname --enable-tests \
    --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \

  runhaskell Setup build
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |"
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |"

check() {
  cd $_hkgname-$pkgver
  runhaskell Setup test

package() {
  cd $_hkgname-$pkgver

  install -D -m744 "$pkgdir"/usr/share/haskell/register/$
  install -D -m744 "$pkgdir"/usr/share/haskell/unregister/$
  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  rm -f "${pkgdir}/usr/share/doc/${pkgname}/LICENSE"

arch-hs will collect the information from hackage db, and apply it into a fixed template after some processing steps including renaming, matching license, and filling out dependencies etc. If the package doesn't have test suits, check() will be removed. However, packaging haven't been done so far. arch-hs may does well statically, but we should guarantee that this package can be built by ghc with the latest dependencies; hence some patchs may be required in prepare().



$ arch-hs -o "/home/berberman/Desktop/test/" termonad

This will generate a series of PKGBUILD including termonad with its dependencies into the output dir.

Flag Assignments

$ arch-hs -f inline-c:gsl-example:true termonad

Using -f can pass flags, which may affect the results of rsolving.

AUR Searching

$ arch-hs -a termonad

Using -a can regard AUR as another package provider. arch-hs will try to search missing packages in AUR.

Skipping Components

$ arch-hs -s termonad-test termonad

Using -s can force skip runnable components in dependency rsolving. This is useful when a package doesn't provide flag to disable its runnables, which will be built by default but are trivial in system level packaging. Notice that this only makes sense in the lifetime of arch-hs, whereas generated PKGBUILD and actual build processes will not be affected.

Extra Cabal Files

$ arch-hs -e /home/berberman/arch-hs/arch-hs.cabal arch-hs

Using -e can can include extra .cabal files as supplementary. Useful when the target like arch-hs hasn't been released to hackage.


$ arch-hs --help
arch-hs - a program generating PKGBUILD for hackage packages.

Usage: arch-hs [-h|--hackage PATH] [-c|--community PATH] [-o|--output PATH] 
               [-f|--flags package_name:flag_name:true|false,...] 
               [-s|--skip component_name,...] [-e|--extra PATH_1,...] [-a|--aur]
  Try to reach the TARGET QAQ.

Available options:
  -h,--hackage PATH        Path to hackage index
                           tarball (default: "~/.cabal/packages/YOUR_HACKAGE_MIRROR/01-index.tar | 00-index.tar")
  -c,--community PATH      Path to
                           community.db (default: "/var/lib/pacman/sync/community.db")
  -o,--output PATH         Output path to generated PKGBUILD files (empty means
                           dry run)
  -f,--flags package_name:flag_name:true|false,...
                           Flag assignments for packages - e.g.
                           inline-c:gsl-example:true (separated by ',')
  -s,--skip component_name,...
                           Skip a runnable component (executable, test suit, or
                           benchmark) in dependency calculation
  -e,--extra PATH_1,...    Extra cabal files' path - e.g.
  -a,--aur                 Enable AUR searching
  -h,--help                Show this help text

For all available options, have a look at the help message.


arch-hs also provides a component called arch-hs-diff. arch-hs-diff can show differences of information used in PKGBUILD between two versions of a hackage package. This is useful in the subsequent maintenance of a package. Example:

$ arch-hs-diff HTTP 4000.3.14 4000.3.15
  ▶ You didn't pass -f, different flag values may make difference in dependency resolving.
  ⓘ Start running...
  ⓘ Downloading cabal file from
  ⓘ Downloading cabal file from
Package: HTTP
Version: 4000.3.14  ⇒  4000.3.15
Synopsis: A library for client-side HTTP
    base  >= && <4.14
    time  >= && <1.10
    array  >= && <0.6
    bytestring  >= && <0.11
    mtl  >=2.0 && <2.3
    network-uri  ==2.6.*
    network  >=2.6 && <3.2
    parsec  >=2.0 && <3.2
    base  >= && <4.15
    time  >= && <1.11
    array  >= && <0.6
    bytestring  >= && <0.11
    mtl  >=2.0 && <2.3
    network-uri  ==2.6.*
    network  >=2.6 && <3.2
    parsec  >=2.0 && <3.2
    deepseq  >= && <1.5
    HUnit  >= && <1.7
    httpd-shed  >=0.4 && <0.5
    mtl  >= && <2.3
    pureMD5  >=0.2.4 && <2.2
    split  >=0.1.3 && <0.3
    test-framework  >=0.2.0 && <0.9
    test-framework-hunit  >=0.3.0 && <0.4
    ⚐ mtl1:
      description: Use the old mtl version 1.
      default: False
      isManual: False
    ⚐ warn-as-error:
      description: Build with warnings-as-errors
      default: False
      isManual: True
    ⚐ conduit10:
      description: Use version 1.0.x or below of the conduit package (for the test suite)
      default: False
      isManual: False
    ⚐ warp-tests:
      description: Test against warp
      default: False
      isManual: True
    ⚐ network-uri:
      description: Get Network.URI from the network-uri package
      default: True
      isManual: False

  ✔ Success!

arch-hs-diff does not require hackage db, it downloads cabal files from hackage server instead.


  • The dependency solver will ONLY expand the dependencies of executables and libraries recursively, because circular dependency lies ubiquitously involving test suites, benchmarks, and their buildTools.

  • Currently, arch-hs's functionality is limited to dependency processing, whereas necessary procedures like file patches, loose of version constraints, etc. are need to be done manually, so DO NOT give too much trust in generated PKGBUILD files.


  • Standardized pretty printing.

  • Structuralized PKGBUILD template.

  • AUR support.

  • Logging system.

  • A watchdog during dependency calculation.

  • Working with given .cabal files which haven't been released to hackage.

  • Using hackage-security to manage hackage index tarball.


Issues and PRs are always welcome. _(:з」∠)_