- GHC
- Cabal
- Grip
- Stack
stack.yaml
shell.nix
- implicit-hie
- haskell-language-server
.gitignore
.envrc
clean.sh
- Nix flake
flake.nix
- zlib
It should be easy to add the following by un-commenting code in flake.nix
:
Checkout this repository:
git clone https://github.com/dsunshi/haskell-flake-template.git <my-project>
cd <my-project>
There are two ways to use the flake:
nix develop
(this would need to be done each time entering the <my-project>
folder.
Allow direnv (once):
direnv allow
Since haskell-flake-template
is it's own git
repository you may want to delete this information and restart your project as it's own git
project. You can do this by:
- Remove all
haskell-flake-template
git
data:
rm -rf .git/
- Create a new
git
project:
git init
Tip
It is also possible to run the included clean.sh
to revert the template into a fresh
state, ready to start a new project (the next steps).
Caution
Once you create your project, this should never be used again.
- Setup Cabal:
cabal init
or
cabal init --non-interactive
Note
In order to add a Haskell library, add the name of the library:
- In
flake.nix
under the comment# Other Haskell modules go here:
inside the variableghc
- In the
build-depends
section of your.cabal
file
In flake.nix
:
ghc = hPkgs.ghcWithPackages (ps:
with ps;
[
# Packages to make available to GHC
ghcid # Needed for nixvim LSP
# Other Haskell modules go here:
microlens
]);
In <my-project>.cabal
:
build-depends: base ^>=4.19.2.0, microlens
if you are facing code completion errors such as:
Caution
Failed to run ["cabal","v2-repl" ...
when using vim/nvim
it may be necesarry to have a hie.yaml
file. This flake includes
a tool gen-hie
which will echo the proper outputs to stdout
. Therefore, if you would like to
auto-generate hie.yaml
it is as simple as:
gen-hie > hie.yaml
in the root directory of your project.
For the sake of cabal, and the haskell-lsp any new modules (haskell source files) need to be
added to your .cabal
file in the other-modules:
section.
Download local hoogle index:
hoogle generate --download