Skip to content

Docker image to build haskell code on Raspberry Pi 4

Notifications You must be signed in to change notification settings

yormi/rpi-haskell-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Haskell Build Environment with Cabal on Raspberry Pi

Still haven't manage to make it work !

I got stuck with an executable that needs glibc to be 2.29 but the current Raspberry OS uses glibc 2.28... (February 1st 2021)

We share this here in case it can help folks out there.

Setup

We need this for a project on Raspberry Pi 4B.

We build on a 8GB RAM with a 32GB SSD.

I suggest using a bigger SSD since we are struggling with storage full issues.

Objectives

Benefit of the haskell-language-server

First, we want to be able to use the latest versions of ghc so that we can use the haskell-language-server when developping... hehe.

With the available package of stack on Raspberry OS, we only managed to get ghc 8.6.3 working but it is too old to be supported by haskell-language-server.

Reduce Build Time

Second, we want a setup that uses cache to reduce build time that is excruciating when building the dependencies :P

Only using the docker cache was not amazing for us since the cache was sometimes invalidated or flushed (!?) and we had to rebuild the dependencies way too often.

Requirements

Host (Raspberry Pi)

  • docker

Fix apt issues

Right now, as of January 31st 2021, we must update the libseccomp for apt to work in docker images:

  • Download info here
wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
sudo dpkg -i libseccomp2_2.5.1-1_armhf.deb

Build the Haskell Build Environment

So ! We want to build an environment with ghc and cabal that we'll be able to use to build our Haskell project on Raspberry Pi.

We can do this running this command with this repo as current working directory:

DOCKER_BUILDKIT=1 DOCKER_CLI_EXPERIMENTAL=enabled docker build . -t haskell-builder

It took me 1h45 to build on the setup described above.

Build with the Environment

Once we have that environment, we can start it with:

docker run -v /home/pi/my-project-root:/project -v /home/pi/cabal-cache:/root/.cabal -it haskell-builder bash

Once in the container shell:

cd project
cabal update # The first time
cabal build

Adapt the paths if needed !

Enjoy :)

Versions used

  • ghc 8.10.3
  • cabal-install 3.2

Stack Users

I suggest using stack2cabal to use the same package version and avoid surprises.

I haven't tried it yet but we got bitten by a different AESON package version already so I am definitely gonna try it !

Ressources that Helped

About

Docker image to build haskell code on Raspberry Pi 4

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages