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