Skip to content

dsunshi/haskell-flake-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Haskell Flake Template

What's included?

C-libraries (often required by Haskell applications):

  • zlib

Optional features

It should be easy to add the following by un-commenting code in flake.nix:

Getting Started

Checkout this repository:

git clone https://github.com/dsunshi/haskell-flake-template.git <my-project>
cd <my-project>

Enable the flake

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

Starting your own project

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:

  1. Remove all haskell-flake-template git data:
rm -rf .git/
  1. 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.

  1. Setup Cabal:
cabal init

or

cabal init --non-interactive

Adding Haskell libraries

Note

In order to add a Haskell library, add the name of the library:

  1. In flake.nix under the comment # Other Haskell modules go here: inside the variable ghc
  2. In the build-depends section of your .cabal file

Example

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

Vim/Nvim

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.

Cabal hints

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.

Optional

Download local hoogle index:

hoogle generate --download

About

Easy to use - batteries included flake for Haskell development with Nix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published