Haskell on Alpine Linux

April 5, 2017

How to run Haskell on Alpine Linux, a Linux distribution built on musc libc and busybox, and which requires only 8 MB of storage for a container and 130 MB of storage for a minimal installation to disk.

Village nestled in valley between beautiful mountain peaks. class=
© 2016 Jace Grandinetti for Unsplash

Tools used in this tutorial:

  1. Stack 1.3.2
  2. Alpine Linux, 3.5.2, Standard x86_64
  3. Virtual Box, 5.1.18

Create a Virtual Server

  1. Download Alpine Linux ISO (78 MB).
  2. Create new Virtual Box of type “Linux” and version “Other Linux (64-bit)”. I gave mine 8 GB of disk used the default VDI disk type.
  3. In “Storage” section of your new Virtual Box, click the text “[Optical Drive] Empty”, and choose the disk image (the ISO) that you just downloaded.
  4. Click start.

Setup Alpine

  1. Login as root (no password).
  2. At prompt, type setup-alpine
  3. Answer prompts. Here are my answers:
    • keyboard: us
    • hostname: beets
    • networking: eth0, dhcp, no manual config
    • root password: root
    • timezone: US/Eastern
    • proxy: none
    • mirror: f (find fastest, takes a minute or two)
    • ssh server: openssh
    • ntp client: chrony
    • disk: sda, sys, y

When disk is done, you should see “Installation is complete. Please reboot.”

Remove ISO from CD drive (force unmount) and then type reboot.

If the clock on your Virtual Box is way off, add the line makestep 1 -1 to /etc/chrony/chrony.conf. This allows chronyd to make big changes to the clock quickly.

Install ghc and stack

Currently the ghc package is only in “edge”, which is the Alpine Linux development tree.

  1. login as root
  2. vi /etc/apk/repositories
  3. comment the v3.5 line and uncomment the three “edge” lines
  4. apk upgrade --update-cache --available
  5. apk add ghc
  6. apk add curl musl-dev zlib-dev
  7. curl -sSL https://get.haskellstack.org/ | sh

Note: you must use the --system-ghc option with stack, as they currently do not provide a binary ghc for Alpine Linux.

Notes


If you see an error or something that could be improved, please let me know. This is a blog about me learning, so I expect I will get some stuff wrong. The best way to reach me is by email: mkbucc1234@gmail.com (after deleting all the numbers).

To make a comment, check for a thread on the haskell subreddit and if there isn't one, then start one up.

Follow on Twitter: @mbucc

Back to the index.