summary refs log tree commit diff
path: root/pkgs/development/compilers/ghc/8.0.2.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2017-09-10 15:36:48 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-01-02 19:50:38 -0500
commita5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13 (patch)
tree8927e57ef63a88d000a96aa3602d24b32743e752 /pkgs/development/compilers/ghc/8.0.2.nix
parente3993464d95b9bcc1ad3a8d27e4216bcccb25ebd (diff)
downloadnixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.tar
nixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.tar.gz
nixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.tar.bz2
nixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.tar.lz
nixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.tar.xz
nixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.tar.zst
nixpkgs-a5cc983c45fc8b2d0f6b7aa70f0f1911d35c1a13.zip
ghc: Clean up, and add `passthru.targetPrefix`, in preparation for cross
No hashes should be changed.
Diffstat (limited to 'pkgs/development/compilers/ghc/8.0.2.nix')
-rw-r--r--pkgs/development/compilers/ghc/8.0.2.nix37
1 files changed, 25 insertions, 12 deletions
diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix
index d475e3438b4..924f927b0bc 100644
--- a/pkgs/development/compilers/ghc/8.0.2.nix
+++ b/pkgs/development/compilers/ghc/8.0.2.nix
@@ -1,21 +1,33 @@
-{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, targetPackages, coreutils
-, hscolour, patchutils, sphinx
+{ stdenv, targetPackages
+, buildPlatform, hostPlatform, targetPlatform
 
-  # If enabled GHC will be build with the GPL-free but slower integer-simple
+# build-tools
+, bootPkgs, hscolour
+, coreutils, fetchurl, fetchpatch, patchutils, perl, sphinx
+
+, libiconv ? null, ncurses
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
   # library instead of the faster but GPLed integer-gmp library.
-, enableIntegerSimple ? false, gmp
-, cross ? null
+  enableIntegerSimple ? false, gmp ? null
 }:
 
+assert !enableIntegerSimple -> gmp != null;
+
 let
   inherit (bootPkgs) ghc;
+
+  # TODO(@Ericson2314) Make unconditional
+  targetPrefix = stdenv.lib.optionalString
+    (targetPlatform != hostPlatform)
+    "${targetPlatform.config}-";
 in
 stdenv.mkDerivation rec {
   version = "8.0.2";
-  name = "ghc-${version}";
+  name = "${targetPrefix}ghc-${version}";
 
   src = fetchurl {
-    url = "https://downloads.haskell.org/~ghc/8.0.2/${name}-src.tar.xz";
+    url = "https://downloads.haskell.org/~ghc/8.0.2/ghc-${version}-src.tar.xz";
     sha256 = "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi";
   };
 
@@ -47,19 +59,20 @@ stdenv.mkDerivation rec {
     "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
   ] ++ stdenv.lib.optional stdenv.isDarwin [
     "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
-  ] ++
+  ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [
     # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
-    lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
+    "--disable-large-address-space"
+  ];
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
   stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
 
   postInstall = ''
-    paxmark m $out/lib/${name}/bin/{ghc,haddock}
+    paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
 
     # Install the bash completion file.
-    install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
+    install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
 
     # Patch scripts to include "readelf" and "cat" in $PATH.
     for i in "$out/bin/"*; do
@@ -70,7 +83,7 @@ stdenv.mkDerivation rec {
   '';
 
   passthru = {
-    inherit bootPkgs;
+    inherit bootPkgs targetPrefix;
   };
 
   meta = {