forked from google/ormolu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
169 lines (168 loc) · 4.57 KB
/
default.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
165
166
167
168
169
{ pkgs ? (import ./nix/nixpkgs { inherit system; })
, system ? builtins.currentSystem
, ormoluCompiler ? "ghc8103"
}:
let
source = pkgs.lib.sourceByRegex ./. [
"^.*\.md$"
"^app.*$"
"^data.*$"
"^ormolu\.cabal$"
"^src.*$"
"^tests.*$"
];
haskellPackages = pkgs.haskell.packages.${ormoluCompiler}.override {
overrides = ormoluOverlay;
};
ormoluOverlay = self: super: {
"ormolu" = super.callCabal2nixWithOptions "ormolu" source "-fdev" { };
};
ormolize = import ./nix/ormolize {
inherit pkgs;
inherit haskellPackages;
};
expectedFailures = [
"Agda"
"aws"
"distributed-process"
"esqueleto"
"fay"
"hlint"
"idris"
"intero"
"leksah"
"pandoc"
"pipes"
"postgrest"
"purescript"
"tensorflow"
];
ormolizedPackages = doCheck:
pkgs.lib.mapAttrs (name: p: ormolize {
package = p;
inherit doCheck;
expectedFailures =
if pkgs.lib.lists.any (x: x == name) expectedFailures
then ./expected-failures + "/${name}.txt"
else null;
}) haskellPackages;
in {
ormolu = haskellPackages.ormolu;
# We put the derivations in another attribute set to avoid building them
# when nix-build is run.
dev = {
ormoluShell =
haskellPackages.shellFor {
packages = ps: [
ps.ormolu
];
buildInputs = [
haskellPackages.cabal-install
haskellPackages.ghcid
];
};
withOrmolu = haskellPackages.shellFor {
packages = ps: [];
buildInputs = [
haskellPackages.cabal-install
haskellPackages.ormolu
];
};
};
inherit ormoluOverlay ormoluCompiler;
hackage = ormolizedPackages false;
hackageTests = with pkgs.lib; pkgs.recurseIntoAttrs (
let ps = [
"Agda"
"QuickCheck"
"ShellCheck"
"aeson"
"attoparsec"
"aws"
"brick"
"capability"
"cassava"
"conduit"
"cryptonite"
"diagrams-core"
"distributed-process"
"esqueleto"
"fay"
"hakyll"
"haxl"
"hedgehog"
"hledger"
"hlint"
"http-client"
"idris"
"intero"
"leksah"
"lens"
"megaparsec"
"optics"
"ormolu"
"pandoc"
"parsec3"
"pipes"
"postgrest"
"purescript"
"servant"
"servant-server"
"stack"
"tensorflow"
"text_1_2_4_0"
"tls"
"yesod-core"
];
in listToAttrs (map (p: nameValuePair p (ormolizedPackages true).${p}) ps)
);
regionTests = pkgs.stdenv.mkDerivation {
name = "ormolu-region-tests";
src = ./region-tests;
buildInputs = [
haskellPackages.ormolu
pkgs.diffutils
];
doCheck = true;
buildPhase = ''
cp src.hs result-all-implicit.hs
ormolu --check-idempotence --mode inplace result-all-implicit.hs
cp src.hs result-all-explicit.hs
ormolu --check-idempotence --mode inplace --start-line 1 --end-line 18 result-all-explicit.hs
cp src.hs result-only-start.hs
ormolu --check-idempotence --mode inplace --start-line 1 result-only-start.hs
cp src.hs result-only-end.hs
ormolu --check-idempotence --mode inplace --end-line 18 result-only-end.hs
cp src.hs result-6-7.hs
ormolu --check-idempotence --mode inplace --start-line 6 --end-line 7 result-6-7.hs
cp src.hs result-6-8.hs
ormolu --check-idempotence --mode inplace --start-line 6 --end-line 8 result-6-8.hs
cp src.hs result-9-12.hs
ormolu --check-idempotence --mode inplace --start-line 9 --end-line 12 result-9-12.hs
cp src.hs result-17-18.hs
ormolu --check-idempotence --mode inplace --start-line 17 --end-line 18 result-17-18.hs
'';
checkPhase = ''
echo result-all-implicit.hs
diff --color=always expected-result-all.hs result-all-implicit.hs
echo result-all-explicit.hs
diff --color=always expected-result-all.hs result-all-explicit.hs
echo result-only-start.hs
diff --color=always expected-result-all.hs result-only-start.hs
echo result-only-end.hs
diff --color=always expected-result-all.hs result-only-end.hs
echo result-6-7.hs
diff --color=always expected-result-6-7.hs result-6-7.hs
echo result-6-8.hs
diff --color=always expected-result-6-8.hs result-6-8.hs
echo result-9-12.hs
diff --color=always expected-result-9-12.hs result-9-12.hs
echo result-17-18.hs
diff --color=always expected-result-17-18.hs result-17-18.hs
'';
installPhase = ''
mkdir "$out"
find . -name '*.hs' -exec cp --parents {} $out \;
'';
};
}