A simplified Haskell + Nix project template and tutorial forked from template-haskell.
Uses IOG's haskell.nix
for setting up an environment containing ghc
, cabal
, hoogle
, and haskell-language-server
.
A flake is a source tree (such as a Git repository) containing a file named flake.nix
in the root directory, which provides a standardized interface to Nix packages. Flakes can have dependencies on other flakes, with a flake.lock
file pinning those dependencies to exact revisions to ensure reproducibility.
Start by installing Nix for your operating system.
- Install
nixFlakes
in your environment with the following command:$ nix-env -iA nixpkgs.nixFlakes
- Edit either
/etc/nix/nix.conf
, or if you are a trusted user,~/.config/nix/nix.conf
, and add the following lines:# Enable `nix` command and flakes experimental-features = nix-command flakes # Binary Cache for Haskell.nix trusted-public-keys = [...] hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= [...] substituters = [...] https://cache.iog.io [...]
Note: if you installed Nix in multi-user mode in the previous section, you'll need to restart the nix-daemon:
$ sudo systemctl restart nix-daemon
- Click the green
Use this template
button at the top right of this repository page, name your project, and clickCreate repository from template
. - Click the
Code
dropdown button on your repository page and copy the HTTPS link. - In a terminal window, enter the directory where you'd like your project to be stored and enter the following, pasting in your repository URL:
$ git clone https://github.com/<your github username>/<your project name>.git
- In your terminal, enter your project directory (i.e.
$ cd <your project name>/
) and run the following command to start the wizard script:$ ./wizard.sh
- Respond to the prompts as follows:
Package name [<your project name>]:
hitENTER
to accept the default.Author name [<your name>]:
hitENTER
to accept the default.Author email [<your email>]:
hitENTER
to accept the default.Reinitialize git history? [Y/n]?
typen
andENTER
.
- Stage, commit and push your changes:
$ git add -A $ git commit -m "Set up project" $ git push