-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefault.nix
270 lines (249 loc) · 7.7 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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
let sources = import (builtins.fetchurl {
url = https://raw.githubusercontent.com/nmattia/niv/v0.2.16/nix/sources.nix;
sha256 = "03fl8wfm2nhdiws7pmfz2kcbf47mv2f8gk30fzg4m07gb5zdv6gv";
}) { sourcesFile = ./nix/sources.json; } ; in
let pkgs = import sources.nixpkgs {}; in
let ghcjsPkgs = pkgs; in
let staticPkgs = pkgs.pkgsStatic; in
let strip = true; in
let
telegram-api-pkg =
{ mkDerivation
, stdenv
, fetchFromGitHub
, aeson
, containers
, http-api-data
, http-client
, servant
, servant-client
, servant-client-core
, mtl
, text
, transformers
, http-media
, http-types
, mime-types
, string-conversions
, binary
, ansi-wl-pprint
, hjpath
, hspec
, http-client-tls
, optparse-applicative
}:
mkDerivation {
pname = "telegram-api";
version = "0.7.1.0";
src = fetchFromGitHub {
owner = "nomeata";
repo = "haskell-telegram-api";
# branch kaleidogen-fork
# see https://github.com/klappvisor/haskell-telegram-api/pull/131
rev = "0fe586a19883329ce11963189759bc044898f670";
sha256 = "sha256-0akdSUrpqgNuWkzPOzcIUb3Szt7pOaweMNDgYPRJKGk=";
};
isLibrary = true;
isExecutable = false;
enableSharedExecutables = false;
enableSharedLibraries = false;
libraryHaskellDepends = [
aeson
containers
http-api-data
http-client
servant
servant-client
servant-client-core
mtl
text
transformers
http-media
http-types
mime-types
string-conversions
binary
ansi-wl-pprint
hjpath
hspec
http-client-tls
optparse-applicative
servant-client
];
license = pkgs.lib.licenses.bsd3;
};
kaleidogen-src = pkgs.lib.sourceByRegex ./. [
".*\.cabal$"
"LICENSE"
"^src.*"
"^vendor.*"
];
staticHaskellPackages = with pkgs.haskell.lib; staticPkgs.haskellPackages.override {
overrides = self: super: {
telegram-api = self.callPackage telegram-api-pkg {};
aws-lambda-haskell-runtime = pkgs.haskell.lib.appendPatch
(unmarkBroken super.aws-lambda-haskell-runtime)
(pkgs.fetchpatch {
# https://github.com/theam/aws-lambda-haskell-runtime/pull/121
url = "https://github.com/theam/aws-lambda-haskell-runtime/commit/fa19268282a5afff7aa0ba8babc723d835bed4f1.patch";
sha256 = "sha256-pHxd3Ox5IIwJhG5bFROqotqmIu60zZ5NkBRRfz8xcnk=";
});
};
};
kaleidogen-lambda = staticHaskellPackages.mkDerivation {
pname = "kaleidogen-lambda";
version = "0.1.0.0";
src = kaleidogen-src;
isLibrary = false;
isExecutable = true;
enableSharedExecutables = false;
enableSharedLibraries = false;
executableHaskellDepends = with staticHaskellPackages; [
base
MonadRandom colour exceptions
hex-text random-shuffle
cryptonite memory
temporary typed-process
aeson aws-lambda-haskell-runtime
JuicyPixels base64-bytestring
telegram-api servant-client
];
license = pkgs.lib.licenses.bsd3;
configureFlags = [
"-flambda"
] ++ pkgs.lib.optionals (!strip) [
"--disable-executable-stripping"
] ;
doCheck = false;
};
function-zip = pkgs.runCommandNoCC "kaleidogen-function.zip" {
buildInputs = [ pkgs.zip ];
} ''
mkdir -p $out
cp ${kaleidogen-lambda}/bin/kaleidogen-amazon-lambda bootstrap
zip $out/function.zip bootstrap
'';
ghcjsHaskellPackages = with pkgs.haskell.lib; ghcjsPkgs.haskell.packages.ghcjs.override {
overrides = self: super: {
ghcjs-dom-jsffi = unmarkBroken super.ghcjs-dom-jsffi;
# System.Process.createPipeInternal: not yet supported on GHCJS
QuickCheck = dontCheck super.QuickCheck;
# gets stuck running the tests in node, it seems
scientific = dontCheck super.scientific;
tasty-quickcheck = dontCheck super.tasty-quickcheck;
zlib = dontCheck super.zlib;
# test suite fails
time-compat = dontCheck super.time-compat;
# Just loops
text-short = dontCheck super.text-short;
# missing dependency
jsaddle = overrideCabal super.jsaddle (drv: {
libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.ghcjs-base ];
});
# bump to newer version
ghcjs-base = super.ghcjs-base.overrideAttrs(d: {
src = pkgs.fetchFromGitHub {
owner = "ghcjs";
repo = "ghcjs-base";
rev = "fbaae59b05b020e91783df122249095e168df53f";
sha256 = "sha256-x6eCAK1Hne0QkV3Loi9YpxbleNHU593E4AO8cbk2vUc=";
};
});
};
};
kaleidogen-web = ghcjsHaskellPackages.mkDerivation {
pname = "kaleidogen";
version = "0.1.0.0";
src = kaleidogen-src;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = with ghcjsHaskellPackages; [
base
MonadRandom colour exceptions
hex-text random-shuffle
ghcjs-dom jsaddle jsaddle-dom
file-embed JuicyPixels
];
license = pkgs.lib.licenses.bsd3;
configureFlags = [
"-f-lambda -fjsaddle -f-android -f-clib -f-sdl"
];
doCheck = false;
};
haskellPackages = with pkgs.haskell.lib; pkgs.haskellPackages.override {
overrides = self: super: {
ghcjs-dom-jsffi = unmarkBroken super.ghcjs-dom-jsffi;
jsaddle-warp = unmarkBroken super.jsaddle-warp;
};
};
kaleidogen-local = haskellPackages.mkDerivation {
pname = "kaleidogen";
version = "0.1.0.0";
src = kaleidogen-src;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = with haskellPackages; [
base
MonadRandom colour exceptions
hex-text random-shuffle
ghcjs-dom jsaddle jsaddle-dom
file-embed JuicyPixels
# The following only for local
jsaddle-warp warp
# For SDL
OpenGL StateVar linear sdl2
];
testHaskellDepends = with haskellPackages; [
QuickCheck tasty tasty-quickcheck
];
license = pkgs.lib.licenses.bsd3;
configureFlags = [
"-f-lambda -fjsaddle -f-android -f-clib -fsdl"
] ;
};
index-html = pkgs.writeText "index.html" ''
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
<script language="javascript" src="all.min.js" defer></script>
</html>
'';
gh-page = pkgs.runCommandNoCC "gh-page" {
buildInputs = [pkgs.closurecompiler];
} ''
mkdir -p $out
mkdir -p $out/demo
cp ${kaleidogen-web}/bin/kaleidogen.jsexe/runmain.js $out
echo "Running closure-compiler"
closure-compiler --compilation_level=ADVANCED_OPTIMIZATIONS --jscomp_off=checkVars \
--warning_level QUIET \
--externs=${kaleidogen-web}/bin/kaleidogen.jsexe/all.js.externs ${kaleidogen-web}/bin/kaleidogen.jsexe/all.js > $out/all.min.js
cp ${kaleidogen-web}/bin/kaleidogen-demo.jsexe/runmain.js $out/demo
cp ${index-html} $out/index.html
echo "Running closure-compiler (demo)"
closure-compiler --compilation_level=ADVANCED_OPTIMIZATIONS --jscomp_off=checkVars \
--warning_level QUIET \
--externs=${kaleidogen-web}/bin/kaleidogen-demo.jsexe/all.js.externs ${kaleidogen-web}/bin/kaleidogen-demo.jsexe/all.js > $out/demo/all.min.js
cp ${index-html} $out/demo/index.html
'';
shell = haskellPackages.shellFor {
packages = p: [ kaleidogen-local ];
buildInputs = [
pkgs.cabal-install
pkgs.ghcid
pkgs.closurecompiler
haskellPackages.haskell-language-server
];
};
in
{ inherit
kaleidogen-lambda
kaleidogen-web
kaleidogen-local
function-zip
shell
gh-page;
}