This is a cookiecutter repository which contains my current Haskell jumping off point. Nix has the concepts of templates but they don't really offer the customizability I am looking for here.
To get this cookiecutter,
nix develop nixpkgs#cookiecutter --command cookiecutter gh:chiroptical/nix-haskell-template
You can install cookiecutter via their directions and run,
cookiecutter gh:chiroptical/nix-haskell-template
This will create a directory with the package name you specify in
cookiecutter
. If you cd
into the directory, you'll see a scaffold for a
Haskell flake project.
You could simply nix develop
, but I tend to prefer direnv and
nix-direnv. To use these, follow their installation procedures
and add a file .envrc
with contents:
use flake
If you see something like,
direnv: error /.../.envrc is blocked. Run `direnv allow` to approve its content
Then direnv is set up properly. If not follow the installation instructions.
Once you enter direnv allow
it will set up your shell with all the packages
in package.yaml
. If you notice builds are installing a bunch of packages,
likely you need to refresh your nix shell via direnv reload
. After that
completes, you should be in the shell! From there you can run make run
which
will compile the project and print the package name you specified when running
cookiecutter. There are some other make targets, e.g. make format
will format
your haskell
and nix
code.
- Define
GHC_OPTIONS
in your.envrc
to pass options toghc