Skip to content

Instantly share code, notes, and snippets.

@Tehnix
Last active May 14, 2020 20:29
Show Gist options
  • Save Tehnix/38efa7ff1215ae49bf17925ce1684266 to your computer and use it in GitHub Desktop.
Save Tehnix/38efa7ff1215ae49bf17925ce1684266 to your computer and use it in GitHub Desktop.
Getting Nix and Miso set up on macOS Catalina

Setting up Nix

Following this thread on getting Nix set up on macOS Catalina, there's a few steps involved (assuming you have no /nix folder):

  1. Set up nix folder: echo 'nix' | sudo tee -a /etc/synthetic.conf

  2. Reboot for it to take effect

  3. Create an APFS volume for Nix (might need to use a different diskX number, check diskutil list for more):

    sudo diskutil apfs addVolume disk1 APFSX Nix -mountpoint /nix
    sudo diskutil enableOwnership /nix
    sudo chflags hidden /nix  # Don't show the Nix volume on the desktop
    echo "LABEL=Nix /nix apfs rw" | sudo tee -a /etc/fstab
  4. Install Nix: sh <(curl https://nixos.org/nix/install) --daemon

At this point, everything works perfectly. However, the nix daemon will fail to start after rebooting. It's simple enough to fix, and I've detailed a workaround in #3125.

Setting up Miso

We are now ready to set up Miso:

nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use miso-haskell
cd ~/GitHub/Clones # Assumes you have a folder set up for clones
git clone https://github.com/dmjio/miso
cd miso/sample-app
nix-build
open ./result/bin/app.jsexe/index.html

For the recommended development with ag -l | entr sh -c 'cabal build', set up the tools via:

nix-env -iA cabal-install entr ag -f '<nixpkgs>'

If you are still inside miso/sample-app, you can jump into a nix shell with nix-shell -A env, and then run ag -l | entr sh -c 'cabal build'.

Miso and Live Reload

It's possible to get live reloading and support for ghcid, by using the sample-miso-jsaddle app instead. Let's set it up:

cd ~/GitHub/Clones/miso/sample-app-jsaddle
nix-shell --run reload # or build a release with: nix-build -A release

This works by switching between GHC and GHCJS depending on the target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment