forked from reflex-frp/reflex-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
675 lines (617 loc) · 25.5 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
668
669
670
671
672
673
674
675
{ nixpkgsFunc ? import ./nixpkgs
, system ? builtins.currentSystem
, config ? {}
, enableLibraryProfiling ? false
, enableExposeAllUnfoldings ? true
, enableTraceReflexEvents ? false
, useFastWeak ? true
, useReflexOptimizer ? false
, useTextJSString ? true
, iosSdkVersion ? "10.2"
, iosSdkLocation ? "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${iosSdkVersion}.sdk"
, iosSupportForce ? false
, nixpkgsOverlays ? []
}:
let iosSupport =
if system != "x86_64-darwin" then false
else if iosSupportForce || builtins.pathExists iosSdkLocation then true
else lib.warn "No iOS sdk found at ${iosSdkLocation}; iOS support disabled. To enable, either install a version of Xcode that provides that SDK or override the value of iosSdkVersion to match your installed version." false;
androidSupport = lib.elem system [ "x86_64-linux" ];
newerHackage = self: super: {
all-cabal-hashes = super.all-cabal-hashes.override {
src-spec = {
owner = "commercialhaskell";
repo = "all-cabal-hashes";
rev = "82a8a1a49240a1b465c95de6fa6bf56323ee858f";
sha256 = "1jdzl5fyp1qcsi1anjig6kglq4jjsdll53nissjcnxpy3jscmarm";
};
};
};
bindHaskellOverlays = self: super: {
haskell = super.haskell // {
overlays = super.overlays or {} // import ./haskell-overlays {
nixpkgs = self;
inherit
haskellLib
fetchFromGitHub hackGet
useFastWeak useReflexOptimizer enableLibraryProfiling enableTraceReflexEvents
useTextJSString enableExposeAllUnfoldings
stage2Script
optionalExtension;
inherit (self) lib;
androidActivity = hackGet ./android-activity;
};
};
};
forceStaticLibs = self: super: {
darwin = super.darwin // {
libiconv = super.darwin.libiconv.overrideAttrs (_:
lib.optionalAttrs (self.stdenv.hostPlatform != self.stdenv.buildPlatform && self.stdenv.hostPlatform.isDarwin) {
postInstall = "rm $out/include/libcharset.h $out/include/localcharset.h";
configureFlags = ["--disable-shared" "--enable-static"];
});
};
};
mobileGhcOverlay = import ./nixpkgs-overlays/mobile-ghc { inherit lib; };
nixpkgsArgs = {
inherit system;
overlays = [
newerHackage
bindHaskellOverlays
forceStaticLibs
mobileGhcOverlay
] ++ nixpkgsOverlays;
config = {
allowUnfree = true;
allowBroken = true; # GHCJS is marked broken in 011c149ed5e5a336c3039f0b9d4303020cff1d86
permittedInsecurePackages = [
"webkitgtk-2.4.11"
];
packageOverrides = pkgs: {
webkitgtk = pkgs.webkitgtk216x;
# cabal2nix's tests crash on 32-bit linux; see https://github.com/NixOS/cabal2nix/issues/272
${if system == "i686-linux" then "cabal2nix" else null} = pkgs.haskell.lib.dontCheck pkgs.cabal2nix;
};
} // config;
};
nixpkgs = nixpkgsFunc nixpkgsArgs;
inherit (nixpkgs) lib fetchurl fetchgit fetchgitPrivate fetchFromGitHub;
nixpkgsCross = {
android = lib.mapAttrs (_: args: if args == null then null else nixpkgsFunc args) rec {
aarch64 = {
system = "x86_64-linux";
inherit (nixpkgsArgs) overlays;
crossSystem = {
config = "aarch64-unknown-linux-android";
arch = "arm64";
libc = "bionic";
withTLS = true;
openssl.system = "linux-generic64";
platform = lib.systems.examples.aarch64-multiplatform;
useAndroidPrebuilt = true;
};
config.allowUnfree = true;
};
aarch32 = {
system = "x86_64-linux";
inherit (nixpkgsArgs) overlays;
crossSystem = {
config = "arm-unknown-linux-androideabi";
arch = "armv7";
libc = "bionic";
withTLS = true;
openssl.system = "linux-generic32";
platform = lib.systems.exmamples.armv7l-hf-multiplatform;
useAndroidPrebuilt = true;
};
config.allowUnfree = true;
};
# Back compat
arm64 = lib.warn "nixpkgsCross.android.arm64 has been deprecated, using nixpkgsCross.android.aarch64 instead." aarch64;
armv7a = lib.warn "nixpkgsCross.android.armv7a has been deprecated, using nixpkgsCross.android.aarch32 instead." aarch32;
arm64Impure = lib.warn "nixpkgsCross.android.arm64Impure has been deprecated, using nixpkgsCross.android.aarch64 instead." aarch64;
armv7aImpure = lib.warn "nixpkgsCross.android.armv7aImpure has been deprecated, using nixpkgsCross.android.aarch32 instead." aarch32;
};
ios =
let config = {
allowUnfree = true;
packageOverrides = p: {
darwin = p.darwin // {
ios-cross = p.darwin.ios-cross.override {
# Depending on where ghcHEAD is in your nixpkgs checkout, you may need llvm 39 here instead
inherit (p.llvmPackages_39) llvm clang;
};
};
buildPackages = p.buildPackages // {
osx_sdk = p.buildPackages.callPackage ({ stdenv }:
let version = "10";
in stdenv.mkDerivation rec {
name = "iOS.sdk";
src = p.stdenv.cc.sdk;
unpackPhase = "true";
configurePhase = "true";
buildPhase = "true";
target_prefix = stdenv.lib.replaceStrings ["-"] ["_"] p.targetPlatform.config;
setupHook = ./scripts/setup-hook-ios.sh;
installPhase = ''
mkdir -p $out/
echo "Source is: $src"
cp -r $src/* $out/
'';
meta = with stdenv.lib; {
description = "The IOS OS ${version} SDK";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.unfree;
};
}) {};
};
};
};
in lib.mapAttrs (_: args: if args == null then null else nixpkgsFunc args) rec {
simulator64 = {
system = "x86_64-darwin";
inherit (nixpkgsArgs) overlays;
crossSystem = {
useIosPrebuilt = true;
# You can change config/arch/isiPhoneSimulator depending on your target:
# aarch64-apple-darwin14 | arm64 | false
# arm-apple-darwin10 | armv7 | false
# i386-apple-darwin11 | i386 | true
# x86_64-apple-darwin14 | x86_64 | true
config = "x86_64-apple-darwin14";
arch = "x86_64";
isiPhoneSimulator = true;
sdkVer = iosSdkVersion;
useiOSCross = true;
openssl.system = "darwin64-x86_64-cc";
libc = "libSystem";
};
inherit config;
};
aarch64 = {
system = "x86_64-darwin";
inherit (nixpkgsArgs) overlays;
crossSystem = {
useIosPrebuilt = true;
# You can change config/arch/isiPhoneSimulator depending on your target:
# aarch64-apple-darwin14 | arm64 | false
# arm-apple-darwin10 | armv7 | false
# i386-apple-darwin11 | i386 | true
# x86_64-apple-darwin14 | x86_64 | true
config = "aarch64-apple-darwin14";
arch = "arm64";
isiPhoneSimulator = false;
sdkVer = iosSdkVersion;
useiOSCross = true;
openssl.system = "ios64-cross";
libc = "libSystem";
};
inherit config;
};
# Back compat
arm64 = lib.warn "nixpkgsCross.ios.arm64 has been deprecated, using nixpkgsCross.ios.aarch64 instead." aarch64;
};
};
haskellLib = nixpkgs.haskell.lib;
filterGit = builtins.filterSource (path: type: !(builtins.any (x: x == baseNameOf path) [".git" "tags" "TAGS" "dist"]));
# Retrieve source that is controlled by the hack-* scripts; it may be either a stub or a checked-out git repo
hackGet = p:
if builtins.pathExists (p + "/git.json") then (
let gitArgs = builtins.fromJSON (builtins.readFile (p + "/git.json"));
in if builtins.elem "@" (lib.stringToCharacters gitArgs.url)
then fetchgitPrivate gitArgs
else fetchgit gitArgs)
else if builtins.pathExists (p + "/github.json") then fetchFromGitHub (builtins.fromJSON (builtins.readFile (p + "/github.json")))
else {
name = baseNameOf p;
outPath = filterGit p;
};
# All imports of sources need to go here, so that they can be explicitly cached
sources = {
ghcjs8_0 = {
boot = hackGet ./ghcjs-8.0/boot;
shims = hackGet ./ghcjs-8.0/shims;
ghcjs = hackGet ./ghcjs-8.0/ghcjs;
};
};
optionalExtension = cond: overlay: if cond then overlay else _: _: {};
overrideCabal = pkg: f: if pkg == null then null else haskellLib.overrideCabal pkg f;
replaceSrc = pkg: src: version: overrideCabal pkg (drv: {
inherit src version;
sha256 = null;
revision = null;
editedCabalFile = null;
});
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)));
};
foreignLibSmuggleHeaders = pkg: overrideCabal pkg (drv: {
postInstall = ''
cd dist/build/${pkg.pname}/${pkg.pname}-tmp
for header in $(find . | grep '\.h'$); do
local dest_dir=$out/include/$(dirname "$header")
mkdir -p "$dest_dir"
cp "$header" "$dest_dir"
done
'';
});
cabal2nixResult = src: builtins.trace "cabal2nixResult is deprecated; use ghc.haskellSrc2nix or ghc.callCabal2nix instead" (ghc.haskellSrc2nix {
name = "for-unknown-package";
src = "file://${src}";
sha256 = null;
});
stage2Script = nixpkgs.runCommand "stage2.nix" {
GEN_STAGE2 = builtins.readFile (nixpkgs.path + "/pkgs/development/compilers/ghcjs/gen-stage2.rb");
buildCommand = ''
echo "$GEN_STAGE2" > gen-stage2.rb && chmod +x gen-stage2.rb
patchShebangs .
./gen-stage2.rb "${sources.ghcjs8_0.boot}" >"$out"
'';
nativeBuildInputs = with nixpkgs; [
ruby cabal2nix
];
} "";
ghcjsCompiler = ghc.callPackage (nixpkgs.path + "/pkgs/development/compilers/ghcjs/base.nix") {
bootPkgs = ghc;
ghcjsSrc = sources.ghcjs8_0.ghcjs;
ghcjsBootSrc = sources.ghcjs8_0.boot;
shims = sources.ghcjs8_0.shims;
stage2 = import stage2Script;
};
ghcjsPackages = nixpkgs.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules") {
ghc = ghcjsCompiler;
compilerConfig = nixpkgs.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix") { inherit haskellLib; };
packageSetConfig = nixpkgs.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules/configuration-ghcjs.nix") { inherit haskellLib; };
inherit haskellLib;
};
# TODO: Figure out why this approach doesn't work; it doesn't seem to evaluate our overridden ghc at all
# ghcjsPackages = nixpkgs.haskell.packages.ghcjs.override {
# ghc = builtins.trace "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ghcjsCompiler;
# };
ghcjs = ghcjs8_0;
ghcjs8_0 = (makeRecursivelyOverridable ghcjsPackages).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghcHEAD = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghcHEAD).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghc = ghc8_0;
ghc8_2 = ghc8_2_1;
ghc8_2_1 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc821).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghc8_0 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc802).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghc7 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc7103).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghc7_8 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc784).override {
overrides = nixpkgs.haskell.overlays.combined;
};
ghcAndroidAarch64 = ghcAndroidAarch64-8_2;
ghcAndroidAarch64-8_2 = (makeRecursivelyOverridable nixpkgsCross.android.aarch64.haskell.packages.ghc821).override {
overrides = nixpkgsCross.android.aarch64.haskell.overlays.combined;
};
ghcAndroidAarch32 = ghcAndroidAarch32-8_2;
ghcAndroidAarch32-8_2 = (makeRecursivelyOverridable nixpkgsCross.android.aarch32.haskell.packages.ghc821).override {
overrides = nixpkgsCross.android.aarch32.haskell.overlays.combined;
};
ghcIosSimulator64 = ghcIosSimulator64-8_2;
ghcIosSimulator64-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.simulator64.haskell.packages.ghc821).override {
overrides = nixpkgsCross.ios.simulator64.haskell.overlays.combined;
};
ghcIosAarch64 = ghcIosAarch64-8_2;
ghcIosAarch64-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch64.haskell.packages.ghc821).override {
overrides = nixpkgsCross.ios.aarch64.haskell.overlays.combined;
};
ghcIosAarch32 = ghcIosAarch32-8_2;
ghcIosAarch32-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch32.haskell.packages.ghc821).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_2 = androidWithHaskellPackages {
ghcAndroidAarch64 = ghcAndroidAarch64-8_2;
ghcAndroidAarch32 = ghcAndroidAarch32-8_2;
};
androidWithHaskellPackages = { ghcAndroidAarch64, ghcAndroidAarch32 }: import ./android {
nixpkgs = nixpkgsFunc { system = "x86_64-linux"; };
inherit nixpkgsCross ghcAndroidAarch64 ghcAndroidAarch32 overrideCabal;
};
nix-darwin = fetchFromGitHub {
owner = "3noch"; # TODO: Update to LnL7 once PR is merged: https://github.com/LnL7/nix-darwin/pull/78
repo = "nix-darwin";
rev = "adfe63988d8e0f07739bc7dafd7249c3a78faf96";
sha256 = "0rca00lajdzf8lf2hgwn6mbmii656dnw725y6nnraz4qf87907zq";
};
# TODO: This should probably be upstreamed to nixpkgs.
plistLib = import (nix-darwin + /modules/launchd/lib.nix) { inherit lib; };
ios = iosWithHaskellPackages ghcIosAarch64;
ios-8_2 = iosWithHaskellPackages ghcIosAarch64-8_2;
iosWithHaskellPackages = ghcIosAarch64: {
buildApp = import ./ios {
inherit ghcIosAarch64 plistLib;
nixpkgs = nixpkgsFunc { system = "x86_64-darwin"; };
};
};
in let this = rec {
inherit nixpkgs
nixpkgsCross
overrideCabal
hackGet
foreignLibSmuggleHeaders
stage2Script
ghc
ghcHEAD
ghc8_2
ghc8_0
ghc7
ghc7_8
ghcIosSimulator64
ghcIosAarch64
ghcIosAarch64-8_2
ghcIosAarch32
ghcIosAarch32-8_2
ghcAndroidAarch64
ghcAndroidAarch64-8_2
ghcAndroidAarch32
ghcAndroidAarch32-8_2
ghcjs
ghcjs8_0
android
androidWithHaskellPackages
ios
iosWithHaskellPackages
filterGit;
# Back compat
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_2 = android-8_2.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
applicationId = "org.reflexfrp.todomvc";
displayName = "Reflex TodoMVC via GHC 8.2";
};
iosReflexTodomvc = ios.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
bundleIdentifier = "org.reflexfrp.todomvc";
bundleName = "Reflex TodoMVC";
};
iosReflexTodomvc-8_2 = ios-8_2.buildApp {
package = p: p.reflex-todomvc;
executableName = "reflex-todomvc";
bundleIdentifier = "org.reflexfrp.todomvc";
bundleName = "Reflex TodoMVC via GHC 8.2";
};
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"
];
attrsToList = s: map (name: { inherit name; value = builtins.getAttr name s; }) (builtins.attrNames s);
mapSet = f: s: builtins.listToAttrs (map ({name, value}: {
inherit name;
value = f value;
}) (attrsToList s));
mkSdist = pkg: pkg.override (oldArgs: {
mkDerivation = drv: oldArgs.mkDerivation (drv // {
postConfigure = ''
./Setup sdist
mkdir "$out"
mv dist/*.tar.gz "$out/${drv.pname}-${drv.version}.tar.gz"
exit 0
'';
doHaddock = false;
});
});
sdists = mapSet mkSdist ghc;
mkHackageDocs = pkg: pkg.override (oldArgs: {
mkDerivation = drv: oldArgs.mkDerivation (drv // {
postConfigure = ''
./Setup haddock --hoogle --hyperlink-source --html --for-hackage --haddock-option=--built-in-themes
cd dist/doc/html
mkdir "$out"
tar cz --format=ustar -f "$out/${drv.pname}-${drv.version}-docs.tar.gz" "${drv.pname}-${drv.version}-docs"
exit 0
'';
doHaddock = false;
});
});
hackageDocs = mapSet mkHackageDocs ghc;
mkReleaseCandidate = pkg: nixpkgs.stdenv.mkDerivation (rec {
name = pkg.name + "-rc";
sdist = mkSdist pkg + "/${pkg.pname}-${pkg.version}.tar.gz";
docs = mkHackageDocs pkg + "/${pkg.pname}-${pkg.version}-docs.tar.gz";
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir "$out"
echo -n "${pkg.pname}-${pkg.version}" >"$out/pkgname"
ln -s "$sdist" "$docs" "$out"
'';
# 'checked' isn't used, but it is here so that the build will fail if tests fail
checked = overrideCabal pkg (drv: {
doCheck = true;
src = sdist;
});
});
releaseCandidates = mapSet mkReleaseCandidate ghc;
androidDevTools = [
ghc.haven
nixpkgs.maven
nixpkgs.androidsdk
];
# Tools that are useful for development under both ghc and ghcjs
generalDevToolsAttrs = haskellPackages:
let nativeHaskellPackages = ghc;
in {
inherit (nativeHaskellPackages)
Cabal
cabal-install
ghcid
hasktags
hlint;
inherit (nixpkgs)
cabal2nix
curl
nix-prefetch-scripts
nodejs
pkgconfig
closurecompiler;
} // (lib.optionalAttrs (!(haskellPackages.ghc.isGhcjs or false) && builtins.compareVersions haskellPackages.ghc.version "8.2" < 0) {
# ghc-mod doesn't currently work on ghc 8.2.2; revisit when https://github.com/DanielG/ghc-mod/pull/911 is closed
# When ghc-mod is included in the environment without being wrapped in justStaticExecutables, it prevents ghc-pkg from seeing the libraries we install
ghc-mod = (nixpkgs.haskell.lib.justStaticExecutables nativeHaskellPackages.ghc-mod);
inherit (haskellPackages) hdevtools;
}) // (lib.optionalAttrs (builtins.compareVersions haskellPackages.ghc.version "7.10" >= 0) {
inherit (nativeHaskellPackages) stylish-haskell; # Recent stylish-haskell only builds with AMP in place
});
generalDevTools = haskellPackages: builtins.attrValues (generalDevToolsAttrs haskellPackages);
nativeHaskellPackages = haskellPackages:
if haskellPackages.isGhcjs or false
then haskellPackages.ghc
else haskellPackages;
workOn = haskellPackages: package: (overrideCabal package (drv: {
buildDepends = (drv.buildDepends or []) ++ generalDevTools (nativeHaskellPackages haskellPackages);
})).env;
workOnMulti' = { env, packageNames, tools ? _: [], shellToolOverrides ? _: _: {} }:
let inherit (builtins) listToAttrs filter attrValues all concatLists;
combinableAttrs = [
"benchmarkDepends"
"benchmarkFrameworkDepends"
"benchmarkHaskellDepends"
"benchmarkPkgconfigDepends"
"benchmarkSystemDepends"
"benchmarkToolDepends"
"buildDepends"
"buildTools"
"executableFrameworkDepends"
"executableHaskellDepends"
"executablePkgconfigDepends"
"executableSystemDepends"
"executableToolDepends"
"extraLibraries"
"libraryFrameworkDepends"
"libraryHaskellDepends"
"libraryPkgconfigDepends"
"librarySystemDepends"
"libraryToolDepends"
"pkgconfigDepends"
"setupHaskellDepends"
"testDepends"
"testFrameworkDepends"
"testHaskellDepends"
"testPkgconfigDepends"
"testSystemDepends"
"testToolDepends"
];
concatCombinableAttrs = haskellConfigs: lib.filterAttrs (n: v: v != []) (lib.listToAttrs (map (name: { inherit name; value = concatLists (map (haskellConfig: haskellConfig.${name} or []) haskellConfigs); }) combinableAttrs));
getHaskellConfig = p: (overrideCabal p (args: {
passthru = (args.passthru or {}) // {
out = args;
};
})).out;
notInTargetPackageSet = p: all (pname: (p.pname or "") != pname) packageNames;
baseTools = generalDevToolsAttrs env;
overriddenTools = attrValues (baseTools // shellToolOverrides env baseTools);
depAttrs = lib.mapAttrs (_: v: filter notInTargetPackageSet v) (concatCombinableAttrs (concatLists [
(map getHaskellConfig (lib.attrVals packageNames env))
[{
buildTools = overriddenTools ++ tools env;
}]
]));
in (env.mkDerivation (depAttrs // {
pname = "work-on-multi--combined-pkg";
version = "0";
license = null;
})).env;
workOnMulti = env: packageNames: workOnMulti' { inherit env packageNames; };
# 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 = drvName: buildInputs: otherDeps: nixpkgs.runCommand drvName {
buildCommand = ''
mkdir "$out"
echo "$propagatedBuildInputs $buildInputs $nativeBuildInputs $propagatedNativeBuildInputs $otherDeps" > "$out/deps"
'';
inherit buildInputs otherDeps;
} "";
# The systems that we want to build for on the current system
cacheTargetSystems = lib.warn "cacheTargetSystems has been deprecated, use cacheBuildSystems" cacheBuildSystems;
cacheBuildSystems = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
];
isSuffixOf = suffix: s:
let suffixLen = builtins.stringLength suffix;
in builtins.substring (builtins.stringLength s - suffixLen) suffixLen s == suffix;
reflexEnv = platform:
let haskellPackages = builtins.getAttr platform this;
ghcWithStuff = if platform == "ghc" || platform == "ghcjs" then haskellPackages.ghcWithHoogle else haskellPackages.ghcWithPackages;
in ghcWithStuff (p: import ./packages.nix { haskellPackages = p; inherit platform; });
tryReflexPackages = generalDevTools ghc
++ builtins.map reflexEnv platforms;
cachePackages =
let otherPlatforms = lib.optionals androidSupport [
"ghcAndroidAarch64"
"ghcAndroidAarch32"
] ++ lib.optional iosSupport "ghcIosAarch64";
in tryReflexPackages
++ builtins.map reflexEnv otherPlatforms
++ lib.optionals androidSupport [
androidDevTools
androidReflexTodomvc
] ++ lib.optionals iosSupport [
iosReflexTodomvc
];
demoVM = (import "${nixpkgs.path}/nixos" {
configuration = {
imports = [
"${nixpkgs.path}/nixos/modules/virtualisation/virtualbox-image.nix"
"${nixpkgs.path}/nixos/modules/profiles/demo.nix"
];
environment.systemPackages = tryReflexPackages;
};
}).config.system.build.virtualBoxOVA;
inherit cabal2nixResult sources system androidSupport iosSupport;
project = args: import ./project this (args ({ pkgs = nixpkgs; } // this));
tryReflexShell = pinBuildInputs ("shell-" + system) tryReflexPackages [];
js-framework-benchmark-src = hackGet ./js-framework-benchmark;
ghcjsExternsJs = ./ghcjs.externs.js;
}; in this