-
Notifications
You must be signed in to change notification settings - Fork 9
/
flake.nix
232 lines (216 loc) · 6.77 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
{
description = "hyperbole overlay, development and hyperbole-examples";
inputs = {
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter/main";
web-view.url = "github:seanhess/web-view";
};
outputs =
{
self,
nixpkgs,
nix-filter,
flake-utils,
pre-commit-hooks,
web-view,
}:
let
packageName = "hyperbole";
examplesName = "hyperbole-examples";
src = nix-filter.lib {
root = ./.;
include = [
"src"
"client/dist"
"test"
"example/Example"
"example/docgen"
"example/BulkUpdate.hs"
"example/HelloWorld.hs"
"example/Main.hs"
"example/DevelMain.hs"
./${packageName}.cabal
./cabal.project
./package.yaml
./fourmolu.yaml
./README.md
./CHANGELOG.md
./LICENSE
];
};
overlay = final: prev: {
haskell = prev.haskell // {
packageOverrides = prev.lib.composeExtensions prev.haskell.packageOverrides (
hfinal: hprev: {
"${packageName}" = hfinal.callCabal2nix packageName src { };
}
);
packages = prev.haskell.packages // {
ghc982 = prev.haskell.packages.ghc982.override (old: {
overrides = prev.lib.composeExtensions (old.overrides or (_: _: { })) (
hfinal: hprev: {
http-api-data = hfinal.http-api-data_0_6_1;
uuid-types = hfinal.uuid-types_1_0_6;
effectful = hfinal.effectful_2_5_0_0;
effectful-core = hfinal.effectful-core_2_5_0_0;
scotty = hfinal.scotty_0_22;
data-default = hfinal.callHackage "data-default" "0.8.0.0" { };
}
);
});
ghc966 = prev.haskell.packages.ghc966.override (old: {
overrides = prev.lib.composeExtensions (old.overrides or (_: _: { })) (
hfinal: hprev: {
effectful = hfinal.effectful_2_5_0_0;
effectful-core = hfinal.effectful-core_2_5_0_0;
http-api-data = hfinal.http-api-data_0_6_1;
uuid-types = hfinal.uuid-types_1_0_6;
data-default = hfinal.callHackage "data-default" "0.8.0.0" { };
}
);
});
};
};
};
in
{
overlays.default = nixpkgs.lib.composeExtensions web-view.overlays.default overlay;
}
// flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
example-src = nix-filter.lib {
root = ./example;
include = [
"Example"
(nix-filter.lib.matchExt "hs")
./example/${examplesName}.cabal
# ./example/cabal.project
"docgen"
];
};
# Define GHC versions list
ghcVersions = [
"966"
"982"
];
overridePkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
# Create an attrset of GHC packages
ghcPkgs = builtins.listToAttrs (
map (ghcVer: {
name = "ghc${ghcVer}";
value = (
overridePkgs.haskell.packages."ghc${ghcVer}".extend (
pkgs.haskell.lib.compose.packageSourceOverrides {
${examplesName} = example-src;
}
)
);
}) ghcVersions
);
pre-commit = pre-commit-hooks.lib.${system}.run {
src = src;
hooks = {
hlint.enable = true;
fourmolu.enable = true;
hpack.enable = true;
nixfmt-rfc-style.enable = true;
flake-checker = {
enable = true;
args = [ "--no-telemetry" ];
};
check-merge-conflicts.enable = true;
};
};
shellCommon = version: {
inherit (pre-commit) shellHook;
# Programs that will be available in the development shell
buildInputs = with pkgs.haskell.packages."ghc${version}"; [
pkgs.nodePackages_latest.webpack-cli
pkgs.nodePackages_latest.webpack
pkgs.nodejs
cabal-install
haskell-language-server
fourmolu
fast-tags
ghcid
pkgs.ghciwatch
pkgs.hpack
];
withHoogle = true;
doBenchmark = true;
CABAL_CONFIG = "/dev/null";
# Ensure that libz.so and other libraries are available to TH
# splices, cabal repl, etc.
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.libz ];
};
exe =
version:
pkgs.haskell.lib.justStaticExecutables self.packages.${system}."ghc${version}-${examplesName}";
in
{
checks = builtins.listToAttrs (
map (version: {
name = "ghc${version}-check-${examplesName}";
value = pkgs.runCommand "ghc${version}-check-example" {
buildInputs = [ (exe version) ];
} "type examples; type docgen; touch $out";
}) ghcVersions
);
apps =
{
default = self.apps.${system}."ghc966-${examplesName}";
}
// builtins.listToAttrs (
# Generate apps
map (version: {
name = "ghc${version}-${examplesName}";
value = {
type = "app";
program = "${exe version}/bin/examples";
};
}) ghcVersions
);
packages =
{
default = self.packages.${system}."ghc982-${examplesName}";
}
// builtins.listToAttrs (
map (version: {
name = "ghc${version}-${examplesName}";
value = ghcPkgs."ghc${version}".${examplesName};
}) ghcVersions
);
devShells =
{
default = self.devShells.${system}.ghc982-shell;
}
// builtins.listToAttrs (
# Generate devShells
map (version: {
name = "ghc${version}-shell";
value = ghcPkgs."ghc${version}".shellFor (
shellCommon version
// {
packages = p: [
p.${packageName}
p.${examplesName}
];
}
);
}) ghcVersions
);
}
);
}