Skip to content

Commit 4130a9f

Browse files
committed
Add haskell-nix.templateHaskell.ghcOptions
1 parent 0ff8947 commit 4130a9f

File tree

5 files changed

+64
-63
lines changed

5 files changed

+64
-63
lines changed

overlays/armv6l-linux.nix

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
final: prev:
2+
let
3+
isLinuxCross =
4+
prev.haskell-nix.haskellLib.isCrossHost
5+
&& prev.hostPlatform.isLinux
6+
&& (prev.hostPlatform.isAarch32
7+
|| prev.hostPlatform.isAarch64
8+
|| prev.hostPlatform.isi686);
9+
10+
in
211
{
3-
haskell-nix = prev.haskell-nix // ({
12+
haskell-nix = prev.haskell-nix // final.lib.optionalAttrs isLinuxCross ({
13+
templateHaskell = builtins.mapAttrs (compiler-nix-name: iserv-proxy-exes:
14+
import ./linux-cross.nix {
15+
inherit (final.stdenv) hostPlatform buildPlatform;
16+
inherit (final) stdenv lib;
17+
inherit (final.pkgsBuildBuild) writeShellScriptBin symlinkJoin;
18+
inherit (final.haskell-nix) haskellLib;
19+
qemu = final.pkgsBuildBuild.qemu;
20+
inherit (final) gmp;
21+
inherit (iserv-proxy-exes) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof;
22+
}) final.haskell-nix.iserv-proxy-exes;
423
defaultModules = prev.haskell-nix.defaultModules ++ [
524
({ pkgs, buildModules, config, lib, ... }:
625
let
7-
withTH = import ./linux-cross.nix {
8-
inherit (pkgs.stdenv) hostPlatform buildPlatform;
9-
inherit (pkgs) stdenv lib;
10-
inherit (pkgs.pkgsBuildBuild) writeShellScriptBin symlinkJoin;
11-
inherit (pkgs.haskell-nix) haskellLib;
12-
# qemu for linux
13-
# Using `buildPackages.buildPackages` here fixes `python3Packages.pygobject3` issue.
14-
qemu = pkgs.buildPackages.buildPackages.qemu;
15-
16-
# wine = pkgs.buildPackages.winePackages.minimal;
17-
# inherit (pkgs.windows) mingw_w64_pthreads;
18-
inherit (pkgs) gmp;
19-
# iserv-proxy needs to come from the buildPackages, as it needs to run on the
20-
# build host.
21-
inherit (final.haskell-nix.iserv-proxy-exes.${config.compiler.nix-name}) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof;
22-
} // {
23-
# we can perform testing of cross compiled test-suites by using wine.
24-
# Therefore let's enable doCrossCheck here!
25-
doCrossCheck = pkgs.stdenv.hostPlatform.isWindows;
26-
};
26+
withTH = final.haskell-nix.templateHaskell.${config.compiler.nix-name};
2727
in prev.haskell-nix.haskellLib.addPackageKeys {
28+
inherit (withTH) configureFlags testWrapper;
29+
30+
setupBuildFlags = map (opt: "--ghc-option=" + opt) withTH.ghcOptions
31+
++ lib.optionals pkgs.stdenv.hostPlatform.isAarch32 (map (opt: "--gcc-option=" + opt) [ "-fno-pic" "-fno-plt" ])
32+
# Also for GHC #15275
33+
++ lib.optionals pkgs.stdenv.hostPlatform.isAarch64 ["--gcc-option=-fPIC"];
34+
35+
enableShared = lib.mkDefault false;
36+
37+
doCrossCheck = true;
38+
2839
packages = {
2940
# clock 0.7.2 needs to be patched to support cross compilation.
3041
clock.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isAarch32 [ ({ version }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ];
31-
# nix calls this package crypto
32-
# cryptonite-openssl.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ];
33-
34-
# http-client.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ];
35-
36-
# conduit.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ];
37-
# streaming-commons.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ];
38-
# x509-system.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ];
39-
# file-embed-lzma.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ];
4042

4143
# Set all of these to [], as these form the
4244
# dependency graph of the libiserv, iserv-proxy, and iserv-remote
@@ -59,7 +61,7 @@ final: prev:
5961
network.setupBuildFlags = [];
6062
unix.setupBuildFlags = [];
6163
};
62-
}// withTH
64+
}
6365
)
6466
];
6567
});

overlays/linux-cross.nix

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ let
3131
# ensure that we get a low pid < 65535 for android (If we run outside)
3232
# of nix build envs.
3333

34-
# we want this to hold only for arm (32 and 64bit) for now.
35-
isLinuxCross = haskellLib.isCrossHost && hostPlatform.isLinux && (hostPlatform.isAarch32 || hostPlatform.isAarch64 || hostPlatform.isi686);
3634
qemuIservWrapperScript = enableProfiling:
3735
let
3836
interpreter =
@@ -58,15 +56,12 @@ let
5856
'';
5957
qemuIservWrapper = symlinkJoin { name = "iserv-wrapper"; paths = [ (qemuIservWrapperScript false) (qemuIservWrapperScript true) ]; };
6058
configureFlags = lib.optional (hostPlatform.isAarch32 || hostPlatform.isAndroid) "--disable-split-sections";
61-
setupBuildFlags = map (opt: "--ghc-option=" + opt) ((lib.optionals isLinuxCross
59+
ghcOptions =
6260
[ "-fexternal-interpreter"
6361
"-pgmi" "${qemuIservWrapper}/bin/iserv-wrapper"
6462
"-L${gmp}/lib"
6563
# Required to work-around https://gitlab.haskell.org/ghc/ghc/issues/15275
66-
] ++ lib.optionals hostPlatform.isAarch64 ["-fPIC"]))
67-
++ lib.optionals hostPlatform.isAarch32 (map (opt: "--gcc-option=" + opt) [ "-fno-pic" "-fno-plt" ])
68-
# Also for GHC #15275
69-
++ lib.optionals hostPlatform.isAarch64 ["--gcc-option=-fPIC"];
64+
] ++ lib.optionals hostPlatform.isAarch64 ["-fPIC"];
7065

7166
# Wrapper for qemu testing
7267
qemuTestWrapper = writeShellScriptBin "test-wrapper" ''
@@ -75,8 +70,6 @@ let
7570
'';
7671

7772
# Choose the appropriate test wrapper
78-
testWrapper = lib.optional isLinuxCross "${qemuTestWrapper}/bin/test-wrapper";
73+
testWrapper = "${qemuTestWrapper}/bin/test-wrapper";
7974

80-
enableShared = lib.mkDefault (!isLinuxCross);
81-
82-
in { inherit configureFlags setupBuildFlags testWrapper enableShared; }
75+
in { inherit configureFlags ghcOptions testWrapper; }

overlays/mingw_w64.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ let
7373
################################################################################
7474
# Build logic (TH support via remote iserv via wine)
7575
#
76-
setupBuildFlags = map (opt: "--ghc-option=" + opt) (lib.optionals hostPlatform.isWindows ([
76+
ghcOptions = lib.optionals hostPlatform.isWindows ([
7777
"-fexternal-interpreter"
7878
"-pgmi" "${wineIservWrapper}/bin/iserv-wrapper"
7979
# TODO: this should be automatically injected based on the extraLibrary.
8080
"-L${mingw_w64_pthreads}/lib"
8181
"-L${mingw_w64_pthreads}/bin"
8282
"-L${gmp}/lib"
83-
]));
83+
]);
8484

8585
################################################################################
8686
# Test logic via wine
@@ -105,4 +105,4 @@ let
105105
'';
106106
testWrapper = lib.optional hostPlatform.isWindows "${wineTestWrapper}/bin/test-wrapper";
107107

108-
in { inherit testWrapper setupBuildFlags configureFlags; }
108+
in { inherit testWrapper ghcOptions configureFlags; }

overlays/windows.nix

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,32 @@ final: prev:
3737
configureFlags = (drv.configureFlags or []) ++ [ "--enable-static --disable-shared" ];
3838
});
3939

40-
haskell-nix = prev.haskell-nix // ({
40+
haskell-nix = prev.haskell-nix // final.lib.optionalAttrs final.stdenv.hostPlatform.isWindows ({
41+
templateHaskell = builtins.mapAttrs (compiler-nix-name: iserv-proxy-exes:
42+
import ./mingw_w64.nix {
43+
inherit (final.stdenv) hostPlatform;
44+
inherit (final.pkgsBuildBuild) lib writeShellScriptBin;
45+
wine = final.pkgsBuildBuild.winePackages.minimal;
46+
inherit (final.windows) mingw_w64_pthreads;
47+
inherit (final) gmp;
48+
inherit (final.pkgsBuildBuild) symlinkJoin;
49+
# iserv-proxy needs to come from the buildPackages, as it needs to run on the
50+
# build host.
51+
inherit (iserv-proxy-exes) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof;
52+
}) final.haskell-nix.iserv-proxy-exes;
4153
defaultModules = prev.haskell-nix.defaultModules ++ [
4254
({ pkgs, buildModules, config, lib, ... }:
4355
let
44-
withTH = import ./mingw_w64.nix {
45-
inherit (pkgs.stdenv) hostPlatform;
46-
inherit (pkgs.pkgsBuildBuild) lib writeShellScriptBin;
47-
wine = pkgs.pkgsBuildBuild.winePackages.minimal;
48-
inherit (pkgs.windows) mingw_w64_pthreads;
49-
inherit (pkgs) gmp;
50-
inherit (pkgs.pkgsBuildBuild) symlinkJoin;
51-
# iserv-proxy needs to come from the buildPackages, as it needs to run on the
52-
# build host.
53-
inherit (final.haskell-nix.iserv-proxy-exes.${config.compiler.nix-name}) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof;
54-
} // {
55-
# we can perform testing of cross compiled test-suites by using wine.
56-
# Therefore let's enable doCrossCheck here!
57-
doCrossCheck = pkgs.stdenv.hostPlatform.isWindows;
58-
};
56+
withTH = final.haskell-nix.templateHaskell.${config.compiler.nix-name};
5957
in prev.haskell-nix.haskellLib.addPackageKeys {
58+
inherit (withTH) configureFlags testWrapper;
59+
60+
setupBuildFlags = map (opt: "--ghc-option=" + opt) withTH.ghcOptions;
61+
62+
# we can perform testing of cross compiled test-suites by using wine.
63+
# Therefore let's enable doCrossCheck here!
64+
doCrossCheck = pkgs.stdenv.hostPlatform.isWindows;
65+
6066
packages = {
6167

6268
# Apply https://github.com/haskell/cabal/pull/6055
@@ -115,7 +121,7 @@ final: prev:
115121
unix-time.components.library.libs = [ pkgs.windows.mingw_w64_pthreads ];
116122
unix-time.postUnpack = "substituteInPlace */cbits/win_patch.h --replace Windows.h windows.h";
117123
};
118-
} // withTH
124+
}
119125
)
120126
];
121127
});

test/cabal.project.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repository head.hackage.ghc.haskell.org
2929
f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89
3030
26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329
3131
7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d
32-
--sha256: sha256-V7cPUrMNDXF+LDrNKUE+co1MEmOquGUQ19Z6dJP8bFA=
32+
--sha256: sha256-EXgjjlBrCHX80zkR5s7APh30dgT3e5O6BgsQRtCxT6c=
3333

3434
repository ghcjs-overlay
3535
url: https://raw.githubusercontent.com/input-output-hk/hackage-overlay-ghcjs/ffb32dce467b9a4d27be759fdd2740a6edd09d0b

0 commit comments

Comments
 (0)