-
Notifications
You must be signed in to change notification settings - Fork 164
/
default.nix
667 lines (620 loc) · 27.1 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
{ nixpkgsFunc ? import ./nixpkgs
, system ? builtins.currentSystem
, config ? { }
, enableLibraryProfiling ? false
, enableExposeAllUnfoldings ? true
, enableTraceReflexEvents ? false
, useFastWeak ? true
, useReflexOptimizer ? false
, useTextJSString ? true # Use an implementation of "Data.Text" that uses the more performant "Data.JSString" from ghcjs-base under the hood.
, useWebkit2Gtk ? false # Enable webkit2gtk to build reflex-dom desktop apps
, __useTemplateHaskell ? true # Deprecated, just here until we remove feature from reflex and stop CIing it
, __useNewerCompiler ? true
, iosSdkVersion ? "16.1"
, nixpkgsOverlays ? []
, haskellOverlays ? [] # TODO deprecate
, haskellOverlaysPre ? []
, haskellOverlaysPost ? haskellOverlays
, hideDeprecated ? false # The moral equivalent of "-Wcompat -Werror" for using reflex-platform.
}:
let iosSupport = system == "x86_64-darwin";
androidSupport = lib.elem system [ "x86_64-linux" ];
ghc86Support = lib.elem system ["x86_64-linux" "x86_64-darwin"];
xcodeVer = {
"16.1" = "14.1";
}.${iosSdkVersion} or (throw "Unknown iosSdkVersion: ${iosSdkVersion}");
# Overlay for GHC which supports the external splices plugin
splicesEval = self: super: {
haskell = super.haskell // {
compiler = super.haskell.compiler // {
ghcSplices-8_6 = (super.haskell.compiler.ghc865.overrideAttrs (drv: {
enableParallelBuilding = false;
src = nixpkgs.hackGet ./haskell-overlays/splices-load-save/dep/ghc-8.6;
# When building from the ghc git repo, ./boot must be run before configuring, whereas
# in the distribution tarball on the haskell.org downloads page, ./boot has already been
# run.
preConfigure = ''
echo ${drv.version} >VERSION
./boot
'' + drv.preConfigure or "";
patches = [
# nixpkgs-21.05 ships with a version of autoreconf that is incompatible with ghc 8.6.5,
# Cf. https://gitlab.haskell.org/ghc/ghc/-/commit/ad2ef3a13f1eb000eab8e3d64592373b91a52806
./haskell-overlays/splices-load-save/ghc-8.6-autoreconf.patch
] ++ super.lib.optionals (super.stdenv.targetPlatform.isDarwin) [
./haskell-overlays/patches/ghc865/fix-big-sur.patch
];
})).override {
bootPkgs = super.haskell.packages.ghc865Binary // {
happy = super.haskell.packages.ghc865Binary.happy_1_19_12;
};
useLdGold = !(self.stdenv.targetPlatform.isAarch32) && self.stdenv.hostPlatform.useAndroidPrebuilt;
enableDocs = false;
enableHaddockProgram = false;
};
ghcSplices-8_10 = (super.haskell.compiler.ghc8107.override {
# New option for GHC 8.10. Explicitly enable profiling builds
enableProfiledLibs = true;
#enableShared = self.stdenv.hostPlatform == self.stdenv.targetPlatform;
#enableShared = false;
bootPkgs = if (super.stdenv.hostPlatform.isAarch64) then (super.haskell.packages.ghc8107Binary // {
happy = super.haskell.packages.ghc8107Binary.happy_1_19_12;
}) else
(super.haskell.packages.ghc865Binary // { happy = super.haskell.packages.ghc865Binary.happy_1_19_12; });
}).overrideAttrs (drv: {
src = nixpkgs.hackGet ./haskell-overlays/splices-load-save/dep/ghc-8.10;
# When building from the ghc git repo, ./boot must be run before configuring, whereas
# in the distribution tarball on the haskell.org downloads page, ./boot has already been
# run.
prePatch = ''
echo ${drv.version} >VERSION
patchShebangs boot
./boot
'' + drv.preConfigure or "";
});
};
packages = super.haskell.packages // {
ghcSplices-8_6 = super.haskell.packages.ghc865.override {
buildHaskellPackages = self.buildPackages.haskell.packages.ghcSplices-8_6;
ghc = self.buildPackages.haskell.compiler.ghcSplices-8_6;
};
ghcSplices-8_10 = super.haskell.packages.ghc8107.override {
buildHaskellPackages = self.buildPackages.haskell.packages.ghcSplices-8_10;
ghc = self.buildPackages.haskell.compiler.ghcSplices-8_10;
};
};
};
};
hackGetOverlay = self: super:
import ./nixpkgs-overlays/hack-get { inherit lib; } self;
bindHaskellOverlays = self: super: {
haskell = super.haskell // {
overlays = super.haskell.overlays or {} // import ./haskell-overlays {
nixpkgs = self;
inherit (self) lib;
haskellLib = self.haskell.lib;
inherit
useFastWeak useReflexOptimizer enableLibraryProfiling enableTraceReflexEvents
useTextJSString enableExposeAllUnfoldings __useTemplateHaskell
haskellOverlaysPre
haskellOverlaysPost
useWebkit2Gtk;
inherit ghcSavedSplices-8_6 ghcSavedSplices-8_10;
};
};
};
forceStaticLibs = self: super: {
darwin = super.darwin // {
libiconv = super.darwin.libiconv.overrideAttrs (_:
lib.optionalAttrs (self.stdenv.hostPlatform != self.stdenv.buildPlatform) {
postInstall = "rm $out/include/libcharset.h $out/include/localcharset.h";
configureFlags = ["--enable-shared" "--enable-static"];
});
};
zlib = super.zlib.override (lib.optionalAttrs
(self.stdenv.hostPlatform != self.stdenv.buildPlatform)
{ static = true; shared = true; });
};
mobileGhcOverlay = import ./nixpkgs-overlays/mobile-ghc { inherit lib; };
allCabalHashesOverlay = import ./nixpkgs-overlays/all-cabal-hashes;
nixpkgsArgs = {
inherit system;
overlays = [
(import ./nixpkgs-overlays/ghc.nix { inherit lib; })
hackGetOverlay
bindHaskellOverlays
forceStaticLibs
splicesEval
mobileGhcOverlay
allCabalHashesOverlay
(self: super: {
runtimeShellPackage = if (self.stdenv.hostPlatform.isGhcjs || self.stdenv.targetPlatform.isiOS)
then super.buildPackages.runtimeShellPackage
else super.runtimeShellPackage;
polkit = super.polkit.override {
gobject-introspection = super.gobject-introspection-unwrapped;
};
darwin = super.darwin.overrideScope (dself: dsuper: {
ios-deploy = dsuper.ios-deploy.overrideAttrs (_: {
version = "1.12.2";
src = self.fetchFromGitHub {
owner = "ios-control";
repo = "ios-deploy";
rev = "ed7de7792d28a5110242748649047a95c95ea917";
sha256 = "082w7j490khfpbv1diwrjixjbg9g93wdr2khyzdhv8xmzzwq4lad";
};
});
});
openjdk16-bootstrap = super.openjdk16-bootstrap.override {
gtkSupport = false;
};
adoptopenjdk-hotspot-bin-16 = super.adoptopenjdk-hotspot-bin-16.override {
gtkSupport = false;
};
sqlite = super.sqlite.overrideAttrs (old: lib.optionalAttrs (self.stdenv.hostPlatform.useAndroidPrebuilt or false) {
postBuild = ''
mkdir -p $debug
'';
});
libiconv = super.libiconv.overrideAttrs (old: lib.optionalAttrs (self.stdenv.hostPlatform.useAndroidPrebuilt or false) {
configureFlags = [ "--disable-shared" "--enable-static" ];
});
libffi = if (self.stdenv.hostPlatform.useAndroidPrebuilt or false) then super.libffi_3_3 else super.libffi;
})
] ++ nixpkgsOverlays;
config = config // {
permittedInsecurePackages = (config.permittedInsecurePackages or []) ++ [
"webkitgtk-2.4.11"
];
# XCode needed for native macOS app
# Obelisk needs it to for some reason
allowUnfree = true;
};
};
nixpkgs = nixpkgsFunc nixpkgsArgs;
inherit (nixpkgs) lib fetchurl fetchgit fetchgitPrivate fetchFromGitHub fetchFromBitbucket;
wasmCross = nixpkgs.hackGet ./wasm-cross;
webGhcSrc = (import (wasmCross + /webghc.nix) { inherit fetchgit; }).ghc8107SplicesSrc;
nixpkgsCross = {
# NOTE(Dylan Green):
# sdkVer 30 is the minimum for android, else we have to use libffi 3.3
# bionic doesn't support/expose memfd_create before sdk30
# https://android.googlesource.com/platform/bionic/+/refs/heads/master/docs/status.md
# Look for "new libc functions in R (API Level 30):", memfd_create will be one of the functions /
# symbols we need to build newer libffi
# This means we'll drop all SDKs pre-30
# NOTE(Dylan Green):
# We don't want to use "isStatic" here as we still rely on shared-objects
# adding "isStatic" completely disables generating most SOs, and we still need them
# for libffi (at the very least). Currently the big issues are caused by the linker attempting (and failing)
# to link against a dynamic crtbegin.o (crtbegin.c) bionic does provide a static crtbegin, although the linker
# defaults to a dynamic version
# TODO(Dylan Green):
# Look into making this a proper static build up into "reflex-todomvc"
android = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec {
aarch64 = {
crossSystem = lib.systems.examples.aarch64-android-prebuilt // {
#isStatic = true;
sdkVer = "30";
};
};
aarch32 = {
crossSystem = lib.systems.examples.armv7a-android-prebuilt // {
#isStatic = true;
sdkVer = "30";
};
};
};
ios = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec {
simulator64 = {
crossSystem = lib.systems.examples.iphone64-simulator // {
isStatic = true;
sdkVer = iosSdkVersion;
inherit xcodeVer;
};
};
aarch64 = {
crossSystem = lib.systems.examples.iphone64 // {
isStatic = true;
sdkVer = iosSdkVersion;
inherit xcodeVer;
};
};
aarch32 = {
crossSystem = lib.systems.examples.iphone32 // {
isStatic = true;
sdkVer = iosSdkVersion;
inherit xcodeVer;
};
};
# Back compat
arm64 = lib.warn "nixpkgsCross.ios.arm64 has been deprecated, using nixpkgsCross.ios.aarch64 instead." aarch64;
};
ghcjs = nixpkgsFunc (nixpkgsArgs // {
crossSystem = lib.systems.examples.ghcjs;
});
wasm = nixpkgsFunc (nixpkgsArgs //
(import wasmCross { inherit nixpkgsFunc; }).nixpkgsCrossArgs webGhcSrc "8.6.5"
);
};
haskellLib = nixpkgs.haskell.lib;
overrideCabal = pkg: f: if pkg == null then null else haskellLib.overrideCabal pkg f;
combineOverrides = old: new: old // new // lib.optionalAttrs (old ? overrides && new ? overrides) {
overrides = lib.composeExtensions old.overrides new.overrides;
};
# Makes sure that old `overrides` from a previous call to `override` are not
# forgotten, but composed. Do this by overriding `override` and passing a
# function which takes the old argument set and combining it. What a tongue
# twister!
makeRecursivelyOverridable = x: x // {
override = new: makeRecursivelyOverridable (x.override (old: (combineOverrides old new)));
};
ghcSavedSplices = if __useNewerCompiler then ghcSavedSplices-8_10 else ghcSavedSplices-8_6;
ghcSavedSplices-8_6 = (makeRecursivelyOverridable nixpkgs.haskell.packages.integer-simple.ghcSplices-8_6).override {
overrides = lib.foldr lib.composeExtensions (_: _: {}) (let
haskellOverlays = nixpkgs.haskell.overlays;
in [
haskellOverlays.combined
(haskellOverlays.saveSplices "8.6")
(self: super: with haskellLib; {
blaze-textual = enableCabalFlag super.blaze-textual "integer-simple";
cryptonite = disableCabalFlag super.cryptonite "integer-gmp";
integer-logarithms = disableCabalFlag super.integer-logarithms "integer-gmp";
scientific = enableCabalFlag super.scientific "integer-simple";
dependent-sum-template = dontCheck super.dependent-sum-template;
generic-deriving = dontCheck super.generic-deriving;
})
]);
};
ghcSavedSplices-8_10 = (makeRecursivelyOverridable nixpkgs.haskell.packages.integer-simple.ghcSplices-8_10).override {
overrides = lib.foldr lib.composeExtensions (_: _: {}) (let
haskellOverlays = nixpkgs.haskell.overlays;
in [
haskellOverlays.combined
(haskellOverlays.saveSplices "8.10")
(self: super: with haskellLib; {
blaze-textual = enableCabalFlag super.blaze-textual "integer-simple";
cryptonite = disableCabalFlag super.cryptonite "integer-gmp";
integer-logarithms = disableCabalFlag super.integer-logarithms "integer-gmp";
scientific = enableCabalFlag super.scientific "integer-simple";
})
]);
};
ghcjs = if __useNewerCompiler then ghcjs8_10 else ghcjs8_6;
ghcjs8_6 = (makeRecursivelyOverridable (nixpkgsCross.ghcjs.haskell.packages.ghcjs86.override (old: {
ghc = old.ghc.override {
bootPkgs = old.ghc.bootPkgs // { happy = old.ghc.bootPkgs.happy_1_19_12; };
cabal-install = import ./haskell-overlays/ghcjs-8.6/cabal-install.nix { inherit nixpkgs; };
ghcjsSrc = import ./haskell-overlays/ghcjs-8.6/src.nix {
inherit (nixpkgs.stdenvNoCC) mkDerivation;
inherit (nixpkgs) fetchgit;
};
};
}))).override {
overrides = nixpkgsCross.ghcjs.haskell.overlays.combined;
};
ghcjs8_10 = (makeRecursivelyOverridable nixpkgsCross.ghcjs.haskell.packages.ghcjs810).override {
overrides = nixpkgsCross.ghcjs.haskell.overlays.combined;
};
wasm = ghcWasm32-8_10;
ghcWasm32-8_10 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable (nixpkgsCross.wasm.haskell.packages.ghcWasm.override (old: {
# Due to the splices changes the parallel build fails while building the libraries
ghc = old.ghc.overrideAttrs (drv: { enableParallelBuilding = false; });
}))).override {
overrides = nixpkgsCross.wasm.haskell.overlays.combined;
});
ghc = if __useNewerCompiler then ghc8_10 else ghc8_6;
ghcHEAD = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghcHEAD).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghc8_10 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc8107).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghc8_6 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc865).override {
overrides = nixpkgs.haskell.overlays.combined;
};
# Takes a package set with `makeRecursivelyOverridable` and ensures that any
# future overrides will be applied to both the package set itself and it's
# build-time package set (`buildHaskellPackages`).
makeRecursivelyOverridableBHPToo = x: x // {
override = new: makeRecursivelyOverridableBHPToo (x.override
(combineOverrides
{
overrides = self: super: {
buildHaskellPackages = super.buildHaskellPackages.override new;
};
}
new));
};
ghcAndroidAarch64 = if __useNewerCompiler then ghcAndroidAarch64-8_10 else ghcAndroidAarch64-8_6;
ghcAndroidAarch64-8_6 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.android.aarch64.haskell.packages.integer-simple.ghcSplices-8_6).override {
overrides = nixpkgsCross.android.aarch64.haskell.overlays.combined;
});
ghcAndroidAarch64-8_10 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.android.aarch64.haskell.packages.integer-simple.ghcSplices-8_10).override {
overrides = nixpkgsCross.android.aarch64.haskell.overlays.combined;
});
ghcAndroidAarch32 = if __useNewerCompiler then ghcAndroidAarch32-8_10 else ghcAndroidAarch32-8_6;
ghcAndroidAarch32-8_6 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.android.aarch32.haskell.packages.integer-simple.ghcSplices-8_6).override {
overrides = nixpkgsCross.android.aarch32.haskell.overlays.combined;
});
ghcAndroidAarch32-8_10 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.android.aarch32.haskell.packages.integer-simple.ghcSplices-8_10).override {
overrides = nixpkgsCross.android.aarch32.haskell.overlays.combined;
});
ghcIosSimulator64-8_6 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.ios.simulator64.haskell.packages.integer-simple.ghcSplices-8_6).override {
overrides = nixpkgsCross.ios.simulator64.haskell.overlays.combined;
});
ghcIosSimulator64-8_10 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.ios.simulator64.haskell.packages.integer-simple.ghcSplices-8_10).override {
overrides = nixpkgsCross.ios.simulator64.haskell.overlays.combined;
});
ghcIosSimulator64 = if __useNewerCompiler then ghcIosSimulator64-8_10 else ghcIosSimulator64-8_6;
ghcIosAarch64 = if __useNewerCompiler then ghcIosAarch64-8_10 else ghcIosAarch64-8_6;
ghcIosAarch64-8_6 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.ios.aarch64.haskell.packages.integer-simple.ghcSplices-8_6).override {
overrides = nixpkgsCross.ios.aarch64.haskell.overlays.combined;
});
ghcIosAarch64-8_10 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.ios.aarch64.haskell.packages.integer-simple.ghcSplices-8_10).override {
overrides = nixpkgsCross.ios.aarch64.haskell.overlays.combined;
});
ghcIosAarch32 = if __useNewerCompiler then ghcIosAarch32-8_10 else ghcIosAarch32-8_6;
ghcIosAarch32-8_6 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.ios.aarch32.haskell.packages.integer-simple.ghcSplices-8_6).override {
overrides = nixpkgsCross.ios.aarch32.haskell.overlays.combined;
});
ghcIosAarch32-8_10 = makeRecursivelyOverridableBHPToo ((makeRecursivelyOverridable nixpkgsCross.ios.aarch32.haskell.packages.integer-simple.ghcSplices-8_10).override {
overrides = nixpkgsCross.ios.aarch32.haskell.overlays.combined;
});
#TODO: Separate debug and release APKs
#TODO: Warn the user that the android app name can't include dashes
android = androidWithHaskellPackages {
inherit ghcAndroidAarch64 ghcAndroidAarch32;
};
android-8_6 = androidWithHaskellPackages {
ghcAndroidAarch64 = ghcAndroidAarch64-8_6;
ghcAndroidAarch32 = ghcAndroidAarch32-8_6;
};
android-8_10 = androidWithHaskellPackages {
ghcAndroidAarch64 = ghcAndroidAarch64-8_10;
ghcAndroidAarch32 = ghcAndroidAarch32-8_10;
};
androidWithHaskellPackages = { ghcAndroidAarch64, ghcAndroidAarch32 }: import ./android {
inherit nixpkgs nixpkgsCross ghcAndroidAarch64 ghcAndroidAarch32 overrideCabal;
acceptAndroidSdkLicenses = config.android_sdk.accept_license or false;
};
iosAarch64 = iosWithHaskellPackages ghcIosAarch64;
iosAarch64-8_6 = iosWithHaskellPackages ghcIosAarch64-8_6;
iosAarch64-8_10 = iosWithHaskellPackages ghcIosAarch64-8_10;
iosAarch32 = iosWithHaskellPackages ghcIosAarch32;
iosAarch32-8_6 = iosWithHaskellPackages ghcIosAarch32-8_6;
iosAarch32-8_10 = iosWithHaskellPackages ghcIosAarch32-8_10;
iosSimulator = {
buildApp = nixpkgs.lib.makeOverridable (import ./ios { inherit nixpkgs; ghc = ghcIosSimulator64; withSimulator = true; });
};
iosWithHaskellPackages = ghc: {
buildApp = nixpkgs.lib.makeOverridable (import ./ios { inherit nixpkgs ghc; });
};
in let this = rec {
inherit (nixpkgs)
filterGit
hackGet
thunkSet
;
inherit nixpkgs
nixpkgsCross
overrideCabal
ghc
ghcHEAD
ghc8_6
ghc8_10
ghcIosSimulator64
ghcIosSimulator64-8_6
ghcIosSimulator64-8_10
ghcIosAarch64
ghcIosAarch64-8_6
ghcIosAarch64-8_10
ghcIosAarch32
ghcIosAarch32-8_6
ghcIosAarch32-8_10
ghcAndroidAarch64
ghcAndroidAarch64-8_6
ghcAndroidAarch64-8_10
ghcAndroidAarch32
ghcAndroidAarch32-8_6
ghcAndroidAarch32-8_10
ghcjs
ghcjs8_6
ghcjs8_10
ghcSavedSplices
ghcSavedSplices-8_6
ghcSavedSplices-8_10
android
androidWithHaskellPackages
iosAarch32
iosAarch64
iosSimulator
iosWithHaskellPackages
wasm
wasmCross
;
# Back compat
ios = iosAarch64;
ghcAndroidArm64 = lib.warn "ghcAndroidArm64 has been deprecated, using ghcAndroidAarch64 instead." ghcAndroidAarch64;
ghcAndroidArmv7a = lib.warn "ghcAndroidArmv7a has been deprecated, using ghcAndroidAarch32 instead." ghcAndroidAarch32;
ghcIosArm64 = lib.warn "ghcIosArm64 has been deprecated, using ghcIosAarch64 instead." ghcIosAarch64;
androidReflexTodomvc = android.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
applicationId = "org.reflexfrp.todomvc";
displayName = "Reflex TodoMVC";
};
androidReflexTodomvc-8_6 = android-8_6.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
applicationId = "org.reflexfrp.todomvc.via_8_6";
displayName = "Reflex TodoMVC via GHC 8.6";
};
androidReflexTodomvc-8_10 = android-8_10.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
applicationId = "org.reflexfrp.todomvc.via_8_10";
displayName = "Reflex TodoMVC via GHC 8.10";
};
iosReflexTodomvc = ios.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
bundleIdentifier = "org.reflexfrp.todomvc";
bundleName = "Reflex TodoMVC";
};
iosReflexTodomvc-8_6 = iosAarch64-8_6.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
bundleIdentifier = "org.reflexfrp.todomvc.via_8_6";
bundleName = "Reflex TodoMVC via GHC 8.6";
};
iosReflexTodomvc-8_10 = iosAarch64-8_10.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
bundleIdentifier = "org.reflexfrp.todomvc.via_8_10";
bundleName = "Reflex TodoMVC via GHC 8.10";
};
iosSimulatorReflexTodomvc = iosSimulator.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
bundleIdentifier = "org.reflexfrp.todomvc";
bundleName = "Reflex TodoMVC";
};
setGhcLibdir = ghcLibdir: inputGhcjs:
let libDir = "$out/lib/ghcjs-${inputGhcjs.version}";
ghcLibdirLink = nixpkgs.stdenv.mkDerivation {
name = "ghc_libdir";
inherit ghcLibdir;
buildCommand = ''
mkdir -p ${libDir}
echo "$ghcLibdir" > ${libDir}/ghc_libdir_override
'';
};
in inputGhcjs // {
outPath = nixpkgs.buildEnv {
inherit (inputGhcjs) name;
paths = [ inputGhcjs ghcLibdirLink ];
postBuild = ''
mv ${libDir}/ghc_libdir_override ${libDir}/ghc_libdir
'';
};
};
platforms = [
"ghcjs"
"ghc"
];
androidDevTools = [
ghc.haven
nixpkgs.maven
nixpkgs.androidsdk_9_0
];
# Tools that are useful for development under both ghc and ghcjs
generalDevTools' = { nativeHaskellPackages ? ghc }: {
inherit (nativeHaskellPackages)
Cabal
cabal-install
ghcid
hasktags
stylish-haskell # Recent stylish-haskell only builds with AMP in place
reflex-ghci
;
inherit (nixpkgs)
cabal2nix
curl
nix-prefetch-scripts
nodejs
pkgconfig
closurecompiler
;
};
workOn = haskellPackages: package: (overrideCabal package (drv: {
buildTools = (drv.buildTools or []) ++ builtins.attrValues (generalDevTools' {});
})).env;
# A minimal wrapper around the build-wasm-app from wasm-cross
# Useful in building simple cabal projects like reflex-todomvc
build-wasm-app-wrapper =
ename: # Name of the executable, usually same as cabal project name
pkgPath : # Path of cabal package
args: # Others options to pass to build-wasm-app
let
pkg = wasm.callPackage pkgPath {};
webabi = nixpkgs.callPackage (wasmCross + /webabi) {};
build-wasm-app = nixpkgs.callPackage (wasmCross + /build-wasm-app.nix) ({ inherit webabi; } // args);
in build-wasm-app {
inherit pkg ename;
};
# A simple derivation that just creates a file with the names of all
# of its inputs. If built, it will have a runtime dependency on all
# of the given build inputs.
pinBuildInputs = name: buildInputs: (nixpkgs.releaseTools.aggregate {
inherit name;
constituents = buildInputs;
}).overrideAttrs (old: {
buildCommand = old.buildCommand + ''
echo "$propagatedBuildInputs $buildInputs $nativeBuildInputs $propagatedNativeBuildInputs" > "$out/deps"
'';
inherit buildInputs;
});
reflexEnv = platform:
let haskellPackages = builtins.getAttr platform this;
ghcWithStuff = if platform == "ghc"
then haskellPackages.ghcWithHoogle
else haskellPackages.ghcWithPackages;
in ghcWithStuff (p: import ./packages.nix {
haskellPackages = p;
inherit platform;
});
tryReflexPackages = builtins.attrValues (generalDevTools' {})
++ builtins.map reflexEnv platforms;
cachePackages =
let otherPlatforms = lib.optionals androidSupport [
(if __useNewerCompiler then "ghcAndroidAarch64-8_10" else "ghcAndroidAarch64")
(if __useNewerCompiler then "ghcAndroidAarch32-8_10" else "ghcAndroidAarch32")
] ++ lib.optionals iosSupport [
(if __useNewerCompiler then "ghcIosAarch64-8_10" else "ghcIosAarch64")
(if __useNewerCompiler then "ghcIosSimulator64-8_10" else "ghcIosSimulator64")
];
in tryReflexPackages
++ builtins.map reflexEnv otherPlatforms
++ lib.optionals androidSupport [
androidDevTools
androidReflexTodomvc
] ++ lib.optionals iosSupport [
iosReflexTodomvc iosSimulatorReflexTodomvc
];
inherit system androidSupport iosSupport ghc86Support;
project = args: import ./project this (args ({ pkgs = nixpkgs; } // this));
tryReflexShell = pinBuildInputs ("shell-" + system) tryReflexPackages;
ghcjsExternsJs = ./ghcjs.externs.js;
};
# Deprecated reexports. These were made for `./scripts/*`, but are reexported
# here for backwards compatibility.
legacy = {
# Added 2019-12, will be removed 2020-06.
inherit
(import ./nix-utils/hackage { reflex-platform = this; })
attrsToList
mapSet
mkSdist
sdists
mkHackageDocs
hackageDocs
mkReleaseCandidate
releaseCandidates
;
generalDevTools = _: builtins.attrValues (this.generalDevTools' {});
generalDevToolsAttrs = _: this.generalDevTools' {};
nativeHaskellPackages = haskellPackages:
if haskellPackages.isGhcjs or false
then haskellPackages.ghc
else haskellPackages;
workOnMulti' = { env, packageNames }:
(import ./nix-utils/work-on-multi {}).workOnMulti {
envFunc = _: env;
inherit packageNames;
};
workOnMulti = env: packageNames: legacy.workOnMulti' { inherit env packageNames; };
};
in this // lib.optionalAttrs
(!hideDeprecated)
(lib.mapAttrs (attrName: builtins.trace "The attribute \"${attrName}\" is deprecated. See reflex-platform's root default.nix.") legacy)