Skip to content

Commit f231e24

Browse files
authored
Merge pull request #804 from reflex-frp/nixpkgs-unstable
Add support for aarch64-darwin and aarch64-linux (uses nixpkgs-22.11)
2 parents 7e35474 + d8d4baf commit f231e24

File tree

23 files changed

+346
-105
lines changed

23 files changed

+346
-105
lines changed

ChangeLog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
This project's release branch is `master`. This log is written from the perspective of the release branch: when changes hit `master`, they are considered released.
44

5+
## v1.2.0.0
6+
7+
* Add support for aarch64-darwin (apple silicon macs) and aarch64-linux. See [docs/platform-support.md](./docs/platform-support.md) for more information about what's supported and what isn't on each platform.
8+
* nixpkgs updated to 22.11
9+
* *Breaking change*: Disable webkit2gtk backend for reflex-dom by default. To enable it, use the useWebkit2Gtk flag in `default.nix`.
10+
* *Breaking change*: Remove deprecated cabal2nixResult
11+
* Haskell Libraries Updates
12+
* reflex-dom 0.6.3.1
13+
* ios: Update ios-deploy to v1.12.2
14+
515
## v1.1.2.0 - 2023-09-07
616

717
* Haskell Libraries Updated

android/impl.nix

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
env: with env;
22
let overrideAndroidCabal = package: overrideCabal package (drv: {
3-
preConfigure = (drv.preConfigure or "") + ''
4-
sed -i 's%^executable *\(.*\)$%executable lib\1.so\n cc-options: -shared -fPIC\n ld-options: -shared -Wl,--gc-sections,--version-script=${./haskellActivity.version},-u,Java_systems_obsidian_HaskellActivity_haskellStartMain,-u,hs_main\n ghc-options: -shared -fPIC -threaded -no-hs-main -lHSrts_thr -lffi -lm -llog%i' *.cabal
3+
# -Wl,--unresolved-symbols=ignore-in-object-files
4+
preConfigure = (drv.preConfigure or "") + ''
5+
export NIX_CFLAGS_LINK="-no-pie -v"
6+
sed -i 's%^executable *\(.*\)$%executable lib\1.so\n cc-options: -no-pie -shared -fPIC\n ld-options: -no-pie -shared -Wl,--gc-sections,--version-script=${./haskellActivity.version},-u,Java_systems_obsidian_HaskellActivity_haskellStartMain,-u,hs_main\n ghc-options: -fPIC -shared -no-pie -threaded -no-hs-main -lHSrts_thr -lffi -lm -llog%i' *.cabal
57
'';
6-
});
8+
# -no-hs-main
9+
configureFlags = (drv.configureFlags or []) ++ [
10+
"--enable-shared"
11+
];
12+
});
13+
/*
14+
overrideAndroidCabal = package: overrideCabal package (drv: {
15+
preConfigure = ''
16+
export NIX_CFLAGS_COMPILE=""
17+
export NIX_CFLAGS_LINK="-v -no-pie"
18+
'';
19+
});
20+
*/
721
androidenv = nixpkgs.androidenv;
822
#TODO: Keep the signing key for dev mode more consistent, e.g. in ~/.config/reflex-platform, so that the app can be reinstalled in-place
923
addDeployScript = src: nixpkgs.runCommand "android-app" {
@@ -14,16 +28,20 @@ let overrideAndroidCabal = package: overrideCabal package (drv: {
1428
substitute ${./deploy.sh} $out/bin/deploy \
1529
--subst-var-by coreutils ${nixpkgs.coreutils} \
1630
--subst-var-by adb ${androidenv.androidPkgs_9_0.platform-tools} \
17-
--subst-var-by java ${nixpkgs.openjdk11} \
31+
--subst-var-by java ${nixpkgs.openjdk17_headless} \
1832
--subst-var-by out $out
1933
chmod +x "$out/bin/deploy"
2034
'';
2135
buildInputs = [ androidenv.androidPkgs_9_0.androidsdk ];
2236
} "";
2337
buildGradleApp = import ./build-gradle-app.nix {
24-
inherit (nixpkgs) stdenv lib jdk gnumake gawk file runCommand
25-
which gradle fetchurl buildEnv;
38+
inherit (nixpkgs) stdenv lib gnumake gawk file runCommand
39+
which fetchurl buildEnv;
2640
inherit androidenv;
41+
gradle = nixpkgs.gradle.override {
42+
java = nixpkgs.buildPackages.openjdk11_headless;
43+
};
44+
jdk = nixpkgs.buildPackages.openjdk17_headless;
2745
};
2846
inherit (nixpkgs.lib) splitString escapeShellArg mapAttrs attrNames concatStrings optionalString;
2947
in {

default.nix

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
, useFastWeak ? true
88
, useReflexOptimizer ? false
99
, useTextJSString ? true # Use an implementation of "Data.Text" that uses the more performant "Data.JSString" from ghcjs-base under the hood.
10+
, useWebkit2Gtk ? false # Enable webkit2gtk to build reflex-dom desktop apps
1011
, __useTemplateHaskell ? true # Deprecated, just here until we remove feature from reflex and stop CIing it
1112
, __useNewerCompiler ? true
1213
, iosSdkVersion ? "16.1"
@@ -19,6 +20,7 @@
1920

2021
let iosSupport = system == "x86_64-darwin";
2122
androidSupport = lib.elem system [ "x86_64-linux" ];
23+
ghc86Support = lib.elem system ["x86_64-linux" "x86_64-darwin"];
2224

2325
xcodeVer = {
2426
"16.1" = "14.1";
@@ -49,13 +51,19 @@ let iosSupport = system == "x86_64-darwin";
4951
bootPkgs = super.haskell.packages.ghc865Binary // {
5052
happy = super.haskell.packages.ghc865Binary.happy_1_19_12;
5153
};
54+
useLdGold = !(self.stdenv.targetPlatform.isAarch32) && self.stdenv.hostPlatform.useAndroidPrebuilt;
55+
enableDocs = false;
56+
enableHaddockProgram = false;
5257
};
5358
ghcSplices-8_10 = (super.haskell.compiler.ghc8107.override {
5459
# New option for GHC 8.10. Explicitly enable profiling builds
5560
enableProfiledLibs = true;
56-
bootPkgs = super.haskell.packages.ghc865Binary // {
57-
happy = super.haskell.packages.ghc865Binary.happy_1_19_12;
58-
};
61+
#enableShared = self.stdenv.hostPlatform == self.stdenv.targetPlatform;
62+
#enableShared = false;
63+
bootPkgs = if (super.stdenv.hostPlatform.isAarch64) then (super.haskell.packages.ghc8107Binary // {
64+
happy = super.haskell.packages.ghc8107Binary.happy_1_19_12;
65+
}) else
66+
(super.haskell.packages.ghc865Binary // { happy = super.haskell.packages.ghc865Binary.happy_1_19_12; });
5967
}).overrideAttrs (drv: {
6068
src = nixpkgs.hackGet ./haskell-overlays/splices-load-save/dep/ghc-8.10;
6169
# When building from the ghc git repo, ./boot must be run before configuring, whereas
@@ -94,7 +102,8 @@ let iosSupport = system == "x86_64-darwin";
94102
useFastWeak useReflexOptimizer enableLibraryProfiling enableTraceReflexEvents
95103
useTextJSString enableExposeAllUnfoldings __useTemplateHaskell
96104
haskellOverlaysPre
97-
haskellOverlaysPost;
105+
haskellOverlaysPost
106+
useWebkit2Gtk;
98107
inherit ghcSavedSplices-8_6 ghcSavedSplices-8_10;
99108
};
100109
};
@@ -105,13 +114,13 @@ let iosSupport = system == "x86_64-darwin";
105114
libiconv = super.darwin.libiconv.overrideAttrs (_:
106115
lib.optionalAttrs (self.stdenv.hostPlatform != self.stdenv.buildPlatform) {
107116
postInstall = "rm $out/include/libcharset.h $out/include/localcharset.h";
108-
configureFlags = ["--disable-shared" "--enable-static"];
117+
configureFlags = ["--enable-shared" "--enable-static"];
109118
});
110-
};
119+
};
111120
zlib = super.zlib.override (lib.optionalAttrs
112121
(self.stdenv.hostPlatform != self.stdenv.buildPlatform)
113-
{ static = true; shared = false; });
114-
};
122+
{ static = true; shared = true; });
123+
};
115124

116125
mobileGhcOverlay = import ./nixpkgs-overlays/mobile-ghc { inherit lib; };
117126

@@ -120,33 +129,53 @@ let iosSupport = system == "x86_64-darwin";
120129
nixpkgsArgs = {
121130
inherit system;
122131
overlays = [
132+
(import ./nixpkgs-overlays/ghc.nix { inherit lib; })
123133
hackGetOverlay
124134
bindHaskellOverlays
125135
forceStaticLibs
126136
splicesEval
127137
mobileGhcOverlay
128138
allCabalHashesOverlay
129139
(self: super: {
130-
binutils-unwrapped = super.binutils-unwrapped.override {
131-
autoreconfHook = lib.optional self.stdenv.buildPlatform.isDarwin super.autoreconfHook269;
140+
141+
runtimeShellPackage = if (self.stdenv.hostPlatform.isGhcjs || self.stdenv.targetPlatform.isiOS)
142+
then super.buildPackages.runtimeShellPackage
143+
else super.runtimeShellPackage;
144+
145+
polkit = super.polkit.override {
146+
gobject-introspection = super.gobject-introspection-unwrapped;
132147
};
133148

134-
# Bump ios-deploy
135-
# - for faster deployments
136-
# - fixes debug deploy with iOS 16/macos 12.3/ xcode 13.4.1
137-
darwin = super.darwin // {
138-
ios-deploy = super.darwin.ios-deploy.overrideAttrs (_: {
139-
version = "HEAD";
149+
darwin = super.darwin.overrideScope (dself: dsuper: {
150+
ios-deploy = dsuper.ios-deploy.overrideAttrs (_: {
151+
version = "1.12.2";
140152
src = self.fetchFromGitHub {
141153
owner = "ios-control";
142154
repo = "ios-deploy";
143-
rev = "b3254438719b6bc82ceab1f630e7d642a9acfac5"; # unreleased
144-
sha256 = "W45Qjr3xqvDWieLBgt4//nthxxcc3hgrJNrpSk7vWj8=";
155+
rev = "ed7de7792d28a5110242748649047a95c95ea917";
156+
sha256 = "082w7j490khfpbv1diwrjixjbg9g93wdr2khyzdhv8xmzzwq4lad";
145157
};
146158
});
159+
});
160+
openjdk16-bootstrap = super.openjdk16-bootstrap.override {
161+
gtkSupport = false;
162+
};
163+
adoptopenjdk-hotspot-bin-16 = super.adoptopenjdk-hotspot-bin-16.override {
164+
gtkSupport = false;
147165
};
166+
167+
sqlite = super.sqlite.overrideAttrs (old: lib.optionalAttrs (self.stdenv.hostPlatform.useAndroidPrebuilt or false) {
168+
postBuild = ''
169+
mkdir -p $debug
170+
'';
171+
});
172+
173+
libiconv = super.libiconv.overrideAttrs (old: lib.optionalAttrs (self.stdenv.hostPlatform.useAndroidPrebuilt or false) {
174+
configureFlags = [ "--disable-shared" "--enable-static" ];
175+
});
176+
177+
libffi = if (self.stdenv.hostPlatform.useAndroidPrebuilt or false) then super.libffi_3_3 else super.libffi;
148178
})
149-
(import ./nixpkgs-overlays/ghc.nix { inherit lib; })
150179
] ++ nixpkgsOverlays;
151180
config = config // {
152181
permittedInsecurePackages = (config.permittedInsecurePackages or []) ++ [
@@ -166,24 +195,41 @@ let iosSupport = system == "x86_64-darwin";
166195
wasmCross = nixpkgs.hackGet ./wasm-cross;
167196
webGhcSrc = (import (wasmCross + /webghc.nix) { inherit fetchgit; }).ghc8107SplicesSrc;
168197
nixpkgsCross = {
198+
# NOTE(Dylan Green):
199+
# sdkVer 30 is the minimum for android, else we have to use libffi 3.3
200+
# bionic doesn't support/expose memfd_create before sdk30
201+
# https://android.googlesource.com/platform/bionic/+/refs/heads/master/docs/status.md
202+
# Look for "new libc functions in R (API Level 30):", memfd_create will be one of the functions /
203+
# symbols we need to build newer libffi
204+
# This means we'll drop all SDKs pre-30
205+
206+
# NOTE(Dylan Green):
207+
# We don't want to use "isStatic" here as we still rely on shared-objects
208+
# adding "isStatic" completely disables generating most SOs, and we still need them
209+
# for libffi (at the very least). Currently the big issues are caused by the linker attempting (and failing)
210+
# to link against a dynamic crtbegin.o (crtbegin.c) bionic does provide a static crtbegin, although the linker
211+
# defaults to a dynamic version
212+
213+
# TODO(Dylan Green):
214+
# Look into making this a proper static build up into "reflex-todomvc"
169215
android = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec {
170216
aarch64 = {
171-
crossSystem = lib.systems.examples.aarch64-android-prebuilt //
172-
{ isStatic = true; };
173-
sdkVer = "30";
217+
crossSystem = lib.systems.examples.aarch64-android-prebuilt // {
218+
#isStatic = true;
219+
sdkVer = "30";
220+
};
174221
};
175222
aarch32 = {
176223
crossSystem = lib.systems.examples.armv7a-android-prebuilt // {
177-
isStatic = true;
178-
# Choose an old version so it's easier to find phones to test on
179-
sdkVer = "23";
224+
#isStatic = true;
225+
sdkVer = "30";
180226
};
181227
};
182228
};
183229
ios = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec {
184230
simulator64 = {
185231
crossSystem = lib.systems.examples.iphone64-simulator // {
186-
#isStatic = true;
232+
isStatic = true;
187233
sdkVer = iosSdkVersion;
188234
inherit xcodeVer;
189235
};
@@ -229,12 +275,6 @@ let iosSupport = system == "x86_64-darwin";
229275
override = new: makeRecursivelyOverridable (x.override (old: (combineOverrides old new)));
230276
};
231277

232-
cabal2nixResult = src: builtins.trace "cabal2nixResult is deprecated; use ghc.haskellSrc2nix or ghc.callCabal2nix instead" (ghc.haskellSrc2nix {
233-
name = "for-unknown-package";
234-
src = "file://${src}";
235-
sha256 = null;
236-
});
237-
238278
ghcSavedSplices = if __useNewerCompiler then ghcSavedSplices-8_10 else ghcSavedSplices-8_6;
239279
ghcSavedSplices-8_6 = (makeRecursivelyOverridable nixpkgs.haskell.packages.integer-simple.ghcSplices-8_6).override {
240280
overrides = lib.foldr lib.composeExtensions (_: _: {}) (let
@@ -269,8 +309,7 @@ let iosSupport = system == "x86_64-darwin";
269309
ghcjs = if __useNewerCompiler then ghcjs8_10 else ghcjs8_6;
270310
ghcjs8_6 = (makeRecursivelyOverridable (nixpkgsCross.ghcjs.haskell.packages.ghcjs86.override (old: {
271311
ghc = old.ghc.override {
272-
bootPkgs = with nixpkgsCross.ghcjs.buildPackages.haskell.packages;
273-
ghc865 // { happy = ghc865.callHackage "happy" "1.19.9" {}; };
312+
bootPkgs = old.ghc.bootPkgs // { happy = old.ghc.bootPkgs.happy_1_19_12; };
274313
cabal-install = import ./haskell-overlays/ghcjs-8.6/cabal-install.nix { inherit nixpkgs; };
275314
ghcjsSrc = import ./haskell-overlays/ghcjs-8.6/src.nix {
276315
inherit (nixpkgs.stdenvNoCC) mkDerivation;
@@ -514,7 +553,6 @@ in let this = rec {
514553
cabal-install
515554
ghcid
516555
hasktags
517-
hlint
518556
stylish-haskell # Recent stylish-haskell only builds with AMP in place
519557
reflex-ghci
520558
;
@@ -589,7 +627,7 @@ in let this = rec {
589627
iosReflexTodomvc iosSimulatorReflexTodomvc
590628
];
591629

592-
inherit cabal2nixResult system androidSupport iosSupport;
630+
inherit system androidSupport iosSupport ghc86Support;
593631
project = args: import ./project this (args ({ pkgs = nixpkgs; } // this));
594632
tryReflexShell = pinBuildInputs ("shell-" + system) tryReflexPackages;
595633
ghcjsExternsJs = ./ghcjs.externs.js;

docs/platform-support.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Supported Platforms
2+
3+
reflex-platform supports building *on* x86_64 and aarch64 linux and macOS systems. It supports building *for* Android, iOS, Javascript, Linux, and macOS targets.
4+
5+
Depending on the build system you are using, you can build for the following targets:
6+
7+
| | Javascript | Android | iOS | Linux x86_64 | Linux aarch64 | macOS (intel) | macOS (m1/m2) |
8+
|---------------|------------|---------|-----|--------------|---------------|---------------|---------------|
9+
| Linux x86_64 ||| || | | |
10+
| Linux aarch64 || | | || | |
11+
| macOS (intel) || || | || |
12+
| macOS (m1/m2) || | | | | ||
13+
14+
* On aarch64 platforms (aarch64-linux and aarch64-darwin), we do not support ghc-8.6.5 or ghcjs-8.6.5.
15+
* From Linux, you can't build for iOS or macOS because the apple toolchain is restricted to macOS.
16+
* Android builds aren't yet supported from macOS.
17+
* When building a desktop app on x86_64-linux you can use webkitgtk, but that isn't yet supported on aarch64-linux. You can, however, build your backend executable and warp-based frontend executables on either architecture.
18+
* When building a desktop app on macOS you can use wkwebview or warp.
19+
* 32-bit android builds are only supported via ghc-8.6.5 because later versions of ghc don't support that platform.
20+
21+
## Binary Caches
22+
23+
Binary caches are provided for x86_64-linux, x86_64-darwin, and aarch64-darwin. We will be adding an aarch64-linux cache in the future.

docs/project-development.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,12 @@ Building the frontend with GHC can drastically speed up build times, and
212212
enables you to test from GHCi for even faster reloads.
213213

214214
JSaddle is a set of libraries that allows Reflex-DOM to swap out its
215-
JavaScript backend easily. By default, Reflex-DOM’s ``mainWidget`` will
216-
work on GHC out of the box, using the ``jsaddle-webkit2gtk`` backend. So
217-
simply building your ``frontend`` package using GHC will produce a
218-
working native program that renders DOM using WebKit. This is
219-
recommended for native desktop releases.
215+
JavaScript backend easily. By default, Reflex-DOM’s ``mainWidget`` will work on
216+
GHC out of the box, using the default backend for your platform (e.g.,
217+
jsaddle-warp on linux, wkwebview on macOS). So simply building your
218+
``frontend`` package using GHC will produce a working program that renders DOM.
219+
To select the webkit2gtk backend for reflex-dom on linux, set the useWebkit2Gtk
220+
flag to true in default.nix. Note that webkit2gtk only works on x86_64-linux.
220221

221222
To build this with ``nix-build``:
222223

haskell-overlays/android/default.nix

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,45 @@ in
1111
self: super: {
1212
_dep = super._dep or {} // thunkSet ./dep;
1313

14-
android-activity = self.callPackage self._dep.android-activity {
15-
inherit (nixpkgs.buildPackages) jdk;
16-
};
17-
14+
android-activity = haskellLib.overrideCabal (self.callCabal2nix "android-activity" (self._dep.android-activity + "/") {
15+
log = nixpkgs.androidndkPkgs_24.libraries;
16+
}) (drv: let
17+
jdk-fixed = (nixpkgs.buildPackages.jdk17.override {
18+
headless = true;
19+
enableGnome2 = false;
20+
enableJavaFX = false;
21+
openjdk17-bootstrap = nixpkgs.buildPackages.openjdk17-bootstrap.override {
22+
gtkSupport = false;
23+
};
24+
});
25+
in {
26+
librarySystemDepends = (drv.librarySystemDepends or []) ++ [ jdk-fixed ];
27+
enableSharedExecutables = true;
28+
enableSharedLibraries = true;
29+
enableStaticLibraries = false;
30+
buildTools = (drv.buildTools or []) ++ [ ];
31+
configureFlags = (drv.configureFlags or []) ++ [
32+
"--enable-shared"
33+
#"-v3"
34+
];
35+
});
36+
1837
syb = haskellLib.overrideCabal super.syb (drv: { jailbreak = true; });
1938
cabal-doctest = null;
2039

2140
# Break version bounds on base for GHC HEAD.
2241
lifted-async = haskellLib.doJailbreak super.lifted-async;
2342
safe-exceptions = haskellLib.doJailbreak super.safe-exceptions;
2443

44+
2545
blaze-textual = haskellLib.enableCabalFlag super.blaze-textual "integer-simple";
2646
cryptonite = haskellLib.disableCabalFlag super.cryptonite "integer-gmp";
27-
47+
48+
OneTuple = haskellLib.overrideCabal super.OneTuple (drv: {
49+
libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ [
50+
self.hashable
51+
];
52+
});
2853
hashable = enableFPic super.hashable;
2954
primitive = enableFPic super.primitive;
3055

@@ -34,6 +59,15 @@ self: super: {
3459
enableSharedExecutables = false;
3560
});
3661

62+
# HACK(Dylan Green):
63+
# Temporary fix for RPATH troubles regarding attoparsec
64+
attoparsec = haskellLib.overrideCabal super.attoparsec (drv: {
65+
preFixup = ''
66+
rm -rf "$(pwd)"
67+
mkdir "$(pwd)"
68+
'';
69+
});
70+
3771
# HACK(matthewbauer):
3872
# Temporary fix for https://github.com/ekmett/free/issues/176
3973
# Optimizations are broken on some ARM-based systems for some reason.

0 commit comments

Comments
 (0)