- A Raspberry Pi 4 with Raspbian 10
- At least a 32GB SD card and probably at least 10GB of free space available.
Increase swap space, switch to a 64-bit kernel to use Nix aarch64 packages,
and use Nix packages where possible. At the time of this writing it was
only necessary to build PureScript (purs
) itself; you can check Hydra to see
if this is still an issue, replacing "20.03" in the URL below with the release
of nixpkgs you are interested in:
We'll need a 64 bit kernel for Nix. The kernel is probalby not as well vetted and stable as the standard 32bit kernel, but nothing terrible has happened for me so far. You can always switch between the two fairly easily if needed.
As a bonus, Nix will allow you to use many other (64 bit) packages on Raspbian, which currently only has a 32 bit userland. I used instructions from here, but the relevant steps should be:
$ sudo apt-get update
$ sudo apt-get -y upgrade
$ ls /boot/kernel*.img # confirm you see "kernel8.img" listed
$ echo "arm_64bit=1" | sudo tee -a /boot/config.txt
$ sudo systemctl reboot
After you reboot, you can confirm you see "aarch64" in the output of uname -a
:
$ uname -a
Linux raspberrypi 4.19.114-v8+ #1303 SMP PREEMPT Tue Apr 7 15:55:30 BST 2020 aarch64 GNU/Linux
For this section and for building PureScript, I relied heavily on another guide.
Building Haskell (and perhaps, PureScript) programs can be memory intensive. Our first mitigating step is to enable and/or increase swap.
Stop swapping:
sudo /etc/init.d/dphys-swapfile stop
Edit the file /etc/dphys-swapfile
to change the size of the swap area by updating the line with CONF_SWAPSIZE
to:
CONF_SWAPSIZE=4096
(As noted by the author:)
This should give you 4GB of swap space, but it appears you get a maximum of 2GB. That’s sufficient, so let’s go with it.
Restart swapping:
sudo /etc/init.d/dphys-swapfile start
The standard install method should work, just go to https://nixos.org/download.html and follow the instructions there and in the terminal.
Once installed, we need to configure nix-channels to use a stable version of nixpkgs rather than unstable, primarily so that we can rely on the nix build cache and not have to build the universe on the Raspberry Pi 4 (trust me you don't want to).
Check your current channel:
$ nix-channel --list
If listed as unstable, change it to the latest release, e.g.:
$ nix-channel --add https://nixos.org/channels/nixos-20.03 nixpkgs
$ nix-channel --list
You should see just the above chanenl now if you took care to use the same alias as existed
for the unstable branch (nixpkgs
in this case).
Now update the channel:
$ nix-channel --update
Clone the PureScript repository
and check out the desired release (e.g. git checkout v0.13.8
).
From the repository root:
$ nix-shell -p stack
$ stack --nix setup
$ stack --nix install --flag purescript:RELEASE --jobs 1
This will take a while - I ran it overnight.
If all went well, you will want to add the installation location to your PATH
.
I also find it useful to initiate the nix environment by default. Taken together,
you can add these two blocks to your $HOME/.profile
(if not already added):
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
export PATH
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
At this point, you may wish to reboot to make sure all shells have the updated environment.
To build a project, load any build tools in a new nix shell
$ nix-shell -p spago yarn
You may need to edit the package.json
to not install purescript, spago, etc, as we
need to use the nix-installed aarch64 binaries.
- purescript-emo8 - An unique functional 2D game engine that can create games with only emoji. (Can be built and played on the RPi4).
- Haskell on Raspberry PI 4
I guess the rendering issues might have occurred because of some lacking of emoji fonts which is owned by the OS or browser.
Emo8 engine itself has no emoji font. It uses just Unicode text. So the apperances depends on the OS or browser.
Is it possible to solve this problem by installing some emoji fonts on the OS, referring to the link below?
You may have already tried it. I’m sorry I did not try it.
https://www.raspberrypi.org/forums/viewtopic.php?t=253484