Setting up Agda via nix on osx, running hello world


Setting up Agda on OSX is not straight-forward, some haskell modules are required and some agda modules are required.

We can of course install these globally, but this pollutes our global namespace.

Alternatively we can use nix-shell to give us a sandboxed environment to use agda.


First install nix on OSX.

Next we want an environment with Agda.

We can use nix-shell for this.

We provide a shell.nix file that tells nix-shell what it needs to setup.

shell.nix should contain dependencies and Agda itself:

  • Agda
  • Agda standard library
  • Haskell ieee library

Looking them up via nixpkgs, their attributes are:

  • haskellPackages.Agda
  • AgdaStdlib

We want agda available to us as a binary so we use mkShell:

pkgs.mkShell {
  name = "agda-with-stdlib";
  buildInputs = [ pkgs.haskellPackages.Agda];
  AGDA_DIR = agdaDir;

We also want ghc used in compiling agda programs to have ieee:

agdaGhc = pkgs.haskellPackages.ghcWithPackages (
  haskellPackages: [ ]

The end result can be seen in this gist

References: @ryanrendorff - gist