Flake checks for Haskell

haskell-template provides a builtin list of flake checks:

  • haskell-language-server check (hlsCheck.enable = true) from haskell-flake: Tests that HLS continues to work with the project.
  • treefmt check: Tests that the project is autoformatted and does not have any hlint warnings.

nix flake check and IFD

You cannot use nix flake check (unless your systems list is singular) due to IFD. You can work around this by using the check-flake flake-parts module; make the following changes to your flake.nix:

  • Add check-flake.url = "github:srid/check-flake"; to β€œinputs”
  • Add inputs.check-flake.flakeModule to β€œimports”

Now you can run the following command 1 to run all flake checks locally for the current system:

nix --option sandbox false build .#check -L

See also

sandbox is being disabled because of an issue with haskell-language-server.