-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
165 lines (130 loc) · 4.56 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
flake-root.url = "github:srid/flake-root";
just-flake.url = "github:juspay/just-flake";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
h2jvm.url = "github:ElaraLang/h2jvm";
diagnose.url = "github:knightzmc/diagnose";
diagnose.flake = false;
megaparsec.url = "github:mrkkrp/megaparsec";
megaparsec.flake = true;
};
outputs = inputs@{ self, pre-commit-hooks, nixpkgs, ... }:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.haskell-flake.flakeModule
inputs.treefmt-nix.flakeModule
inputs.flake-root.flakeModule
inputs.just-flake.flakeModule
];
perSystem = { self', lib, system, config, pkgs, ... }: {
haskellProjects.default = {
autoWire = [ "packages" "apps" "checks" ]; # Wire all but the devShell
basePackages = pkgs.haskell.packages.ghc965;
packages = {
h2jvm.source = inputs.h2jvm;
diagnose.source = inputs.diagnose;
megaparsec.source = inputs.megaparsec;
polysemy-test.source = "0.9.0.0";
};
settings = {
fourmolu.check = false;
polysemy-test.jailbreak = true;
polysemy-conc.jailbreak = true;
polysemy-log.jailbreak = true;
diagnose = {
extraBuildDepends = [
pkgs.haskellPackages.megaparsec_9_6_1
];
cabalFlags.megaparsec-compat = true;
jailbreak = true;
};
type-errors = {
extraSetupDepends = [ pkgs.haskellPackages.doctest ];
extraBuildDepends = [ pkgs.haskellPackages.doctest ];
check = false;
};
h2jvm = {
# Skip the tests due to conflicting base version
check = false;
};
ghcid = {
separateBinOutput = false;
};
crypton-x509 = { check = false; };
};
devShell = {
tools = hp: {
treefmt = config.treefmt.build.wrapper;
} // config.treefmt.build.programs;
hlsCheck.enable = false;
};
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
settings = {
treefmt.package = config.treefmt.build.wrapper;
};
hooks = {
treefmt.enable = true;
};
};
};
just-flake.features = {
treefmt.enable = true;
};
treefmt.config = {
inherit (config.flake-root) projectRootFile;
package = pkgs.treefmt;
programs.ormolu.enable = true;
programs.nixpkgs-fmt.enable = true;
programs.cabal-fmt.enable = false;
programs.hlint.enable = true;
# Use fourmolu
programs.ormolu.package = pkgs.haskellPackages.fourmolu;
};
packages.default = self'.packages.elara;
devShells.default = pkgs.mkShell {
inputsFrom = [
config.haskellProjects.default.outputs.devShell
config.flake-root.devShell
config.just-flake.outputs.devShell
];
inherit (self.checks.${system}.pre-commit-check) shellHook;
nativeBuildInputs = [ pkgs.just pkgs.convco ];
buildInputs =
let
stack-wrapped = pkgs.symlinkJoin
{
name = "stack"; # will be available as the usual `stack` in terminal
paths = [ pkgs.stack ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/stack \
--add-flags "\
--no-nix \
--system-ghc \
--no-install-ghc \
"
'';
};
in
[
stack-wrapped
pkgs.haskellPackages.haskell-debug-adapter
pkgs.haskellPackages.ghci-dap
pkgs.haskellPackages.hpack
pkgs.git-cliff
];
};
};
};
}