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 {
18 (fileFilter (file: lib.any file.hasExt [ "hs" ]) ./src)
19 #(fileFilter (file: lib.any file.hasExt [ "hs" ]) ./tests)
22 perSystem = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
24 pkgs = inputs.nixpkgs.legacyPackages.${system};
25 haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; finalHaskellPkgs: previousHaskellPkgs: {
26 ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg fileInputs { });
32 packages = perSystem ({ haskellPackages, ... }: {
33 default = haskellPackages.${pkg};
35 # nix -L develop or direnv allow
36 devShells = perSystem ({ pkgs, haskellPackages, system, ... }: {
38 haskellPackages.shellFor {
39 packages = ps: [ ps.${pkg} ];
41 haskellPackages.cabal-fmt
42 haskellPackages.cabal-install
44 haskellPackages.haskell-language-server
50 inherit (checks.${system}.git-hooks-check) shellHook;
54 checks = perSystem (args: with args; {
55 git-hooks-check = inputs.git-hooks.lib.${system}.run {
58 cabal-fmt.enable = true;
59 fourmolu.enable = true;
61 nixpkgs-fmt.enable = true;
62 ormolu.settings.cabalDefaultExtensions = true;
65 entry = "${pkgs.reuse}/bin/reuse lint";
66 pass_filenames = false;