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.
Tools used in this tutorial:
- Stack 1.3.2
- Alpine Linux, 3.5.2, Standard x86_64
- Virtual Box, 5.1.18
Create a Virtual Server
- Download Alpine Linux ISO (78 MB).
- 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.
- 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.
- Click start.
- Login as root (no password).
- At prompt, type
- 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
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.
- login as root
- vi /etc/apk/repositories
- comment the v3.5 line and uncomment the three “edge” lines
- apk upgrade --update-cache --available
- apk add ghc
- apk add curl musl-dev zlib-dev
- 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.
- Alpine Linux seems to be a favorite base for Docker containers (because of small size).
- Once Haskell is compiled, executable should run on x86_64 Alpine Linux without ghc and thus with stable packages.
- Simple, “old-fashioned” Linux: no systemd!
- You need to install man pages, don’t come by default.
- Startup and shutdown of Virtual Box with Alpine Linux is very fast.
Tags: haskell alpine