3 nixpkgs.url = "flake:nixpkgs";
4 git-hooks.url = "github:cachix/git-hooks.nix";
5 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
10 lib = inputs.nixpkgs.lib;
11 fileInputs = with lib.fileset; toSource {
16 (fileFilter (file: lib.any file.hasExt [ ".hs" ]) ./src)
17 (fileFilter (file: lib.any file.hasExt [ ".hs" ]) ./tests)
20 forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
22 pkgs = inputs.nixpkgs.legacyPackages.${system};
23 haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; hfinal: hsuper: {
24 ${pkg} = buildFromSdist (hfinal.callCabal2nix pkg fileInputs { });
30 packages = forAllSystems ({ haskellPackages, ... }: {
31 default = haskellPackages.${pkg};
33 # nix -L develop or direnv allow
34 devShells = forAllSystems ({ pkgs, haskellPackages, system, ... }: {
36 haskellPackages.shellFor {
37 packages = ps: [ ps.${pkg} ];
39 haskellPackages.cabal-install
41 haskellPackages.haskell-language-server
47 inherit (checks.${system}.git-hooks-check) shellHook;
51 checks = forAllSystems (args: with args; {
52 git-hooks-check = inputs.git-hooks.lib.${system}.run {
55 ormolu.settings.cabalDefaultExtensions = true;
56 cabal-fmt.enable = true;
57 fourmolu.enable = true;
59 nixpkgs-fmt.enable = true;
62 entry = "${pkgs.reuse}/bin/reuse lint";
63 pass_filenames = false;