simple-haskell-project is a convenient script that sets up a haskell project containing:
Check out the example projects in example projects.
Simply run:
source <(curl -s https://raw.githubusercontent.com/Josemarialanda/simple-haskell-project/master/shp.sh) run
This will create a nix flake + cabal based project in the folder a-basic-app.
You can enter the Nix shell with nix develop
. From within the shell you can use cabal to enter the repl with cabal repl
and you can build your project with cabal build
.
You can also build your project with nix instead using nix build
.
Note: While the script itself does not depend on cabal or nix to run, in order to build/enter the development shell of your newly created project you do need to have nix + flakes installed.
On NixOS set the following options in configuration.nix and run nixos-rebuild
.
{ pkgs, ... }: {
nix.settings.experimental-features = [ "nix-command" "flakes" ];
}
On non-nixos systems, edit either ~/.config/nix/nix.conf or /etc/nix/nix.conf and add:
experimental-features = nix-command flakes
Here’s a handy copy-paste:
mkdir -p ~/.config/nix
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf