]> Git — Sourcephile - haskell/logic.git/blob - flake.nix
init
[haskell/logic.git] / flake.nix
1 {
2 inputs = {
3 nixpkgs.url = "flake:nixpkgs";
4 git-hooks.url = "github:cachix/git-hooks.nix";
5 git-hooks.inputs.nixpkgs.follows = "nixpkgs";
6 };
7 outputs = inputs:
8 let
9 pkg = "logic";
10 lib = inputs.nixpkgs.lib;
11 fileInputs = with lib.fileset; toSource {
12 root = ./.;
13 fileset = unions [
14 ./logic.cabal
15 ./ChangeLog.md
16 ./Readme.md
17 ./LICENSES
18 (fileFilter (file: lib.any file.hasExt [ "hs" ]) ./src)
19 #(fileFilter (file: lib.any file.hasExt [ "hs" ]) ./tests)
20 ];
21 };
22 perSystem = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
23 inherit system;
24 pkgs = inputs.nixpkgs.legacyPackages.${system};
25 haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; finalHaskellPkgs: previousHaskellPkgs: {
26 ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg fileInputs { });
27 });
28 });
29 in
30 rec {
31 # nix -L build
32 packages = perSystem ({ haskellPackages, ... }: {
33 default = haskellPackages.${pkg};
34 });
35 # nix -L develop or direnv allow
36 devShells = perSystem ({ pkgs, haskellPackages, system, ... }: {
37 default =
38 haskellPackages.shellFor {
39 packages = ps: [ ps.${pkg} ];
40 nativeBuildInputs = [
41 haskellPackages.cabal-fmt
42 haskellPackages.cabal-install
43 haskellPackages.ghcid
44 haskellPackages.haskell-language-server
45 haskellPackages.hlint
46 pkgs.git-chglog
47 pkgs.reuse
48 ];
49 withHoogle = false;
50 inherit (checks.${system}.git-hooks-check) shellHook;
51 };
52 });
53 # nix flake check
54 checks = perSystem (args: with args; {
55 git-hooks-check = inputs.git-hooks.lib.${system}.run {
56 src = ./.;
57 hooks = {
58 cabal-fmt.enable = true;
59 fourmolu.enable = true;
60 hlint.enable = true;
61 nixpkgs-fmt.enable = true;
62 ormolu.settings.cabalDefaultExtensions = true;
63 reuse = {
64 enable = true;
65 entry = "${pkgs.reuse}/bin/reuse lint";
66 pass_filenames = false;
67 };
68 };
69 };
70 });
71 };
72 }