Merge pull request #13131 from Ericson2314/haskell-cross-rebase

Generalize some GHCJS stuff for other cross compilers

+72 -104
+6 -1
pkgs/development/compilers/ghc/7.10.2.nix
··· 1 - { stdenv, fetchurl, fetchpatch, ghc, perl, gmp, ncurses, libiconv, binutils, coreutils 1 + { stdenv, fetchurl, fetchpatch, bootPkgs, perl, gmp, ncurses, libiconv, binutils, coreutils 2 2 , libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour 3 3 }: 4 4 5 5 let 6 + inherit (bootPkgs) ghc; 6 7 7 8 buildMK = '' 8 9 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp}/lib" ··· 59 60 sed -i -e '2i export PATH="$PATH:${binutils}/bin:${coreutils}/bin"' $i 60 61 done 61 62 ''; 63 + 64 + passthru = { 65 + inherit bootPkgs; 66 + }; 62 67 63 68 meta = { 64 69 homepage = "http://haskell.org/ghc";
+6 -1
pkgs/development/compilers/ghc/7.10.3.nix
··· 1 - { stdenv, fetchurl, fetchpatch, ghc, perl, gmp, ncurses, libiconv, binutils, coreutils 1 + { stdenv, fetchurl, fetchpatch, bootPkgs, perl, gmp, ncurses, libiconv, binutils, coreutils 2 2 , libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour 3 3 }: 4 4 5 5 let 6 + inherit (bootPkgs) ghc; 6 7 7 8 docFixes = fetchurl { 8 9 url = "https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3a.patch"; ··· 60 61 sed -i -e '2i export PATH="$PATH:${binutils}/bin:${coreutils}/bin"' $i 61 62 done 62 63 ''; 64 + 65 + passthru = { 66 + inherit bootPkgs; 67 + }; 63 68 64 69 meta = { 65 70 homepage = "http://haskell.org/ghc";
+9 -1
pkgs/development/compilers/ghc/8.0.1.nix
··· 1 - { stdenv, fetchurl, fetchpatch, ghc, perl, gmp, ncurses, libiconv, binutils, coreutils 1 + { stdenv, fetchurl, fetchpatch, bootPkgs, perl, gmp, ncurses, libiconv, binutils, coreutils 2 2 , hscolour 3 3 }: 4 4 5 + let 6 + inherit (bootPkgs) ghc; 7 + 8 + in 5 9 stdenv.mkDerivation rec { 6 10 version = "8.0.0.20160204"; 7 11 name = "ghc-${version}"; ··· 50 54 sed -i -e '2i export PATH="$PATH:${binutils}/bin:${coreutils}/bin"' $i 51 55 done 52 56 ''; 57 + 58 + passthru = { 59 + inherit bootPkgs; 60 + }; 53 61 54 62 meta = { 55 63 homepage = "http://haskell.org/ghc";
+9 -2
pkgs/development/compilers/ghc/head.nix
··· 1 - { stdenv, fetchgit, ghc, perl, gmp, ncurses, libiconv, binutils, coreutils 1 + { stdenv, fetchgit, bootPkgs, perl, gmp, ncurses, libiconv, binutils, coreutils 2 2 , autoconf, automake, happy, alex 3 3 }: 4 4 5 - stdenv.mkDerivation rec { 5 + let 6 + inherit (bootPkgs) ghc; 7 + 8 + in stdenv.mkDerivation rec { 6 9 version = "7.11.20151216"; 7 10 name = "ghc-${version}"; 8 11 rev = "28638dfe79e915f33d75a1b22c5adce9e2b62b97"; ··· 61 64 sed -i -e '2i export PATH="$PATH:${binutils}/bin:${coreutils}/bin"' $i 62 65 done 63 66 ''; 67 + 68 + passthru = { 69 + inherit bootPkgs; 70 + }; 64 71 65 72 meta = { 66 73 homepage = "http://haskell.org/ghc";
+6 -1
pkgs/development/compilers/ghc/nokinds.nix
··· 1 - { stdenv, fetchgit, ghc, perl, gmp, ncurses, libiconv, autoconf, automake, happy, alex }: 1 + { stdenv, fetchgit, bootPkgs, perl, gmp, ncurses, libiconv, autoconf, automake, happy, alex }: 2 2 3 3 let 4 + inherit (bootPkgs) ghc; 4 5 5 6 buildMK = '' 6 7 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp}/lib" ··· 65 66 # required, because otherwise all symbols from HSffi.o are stripped, and 66 67 # that in turn causes GHCi to abort 67 68 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; 69 + 70 + passthru = { 71 + inherit bootPkgs; 72 + }; 68 73 69 74 meta = { 70 75 homepage = "http://haskell.org/ghc";
+8 -4
pkgs/development/compilers/ghcjs/default.nix
··· 20 20 , ghcjs-prim 21 21 , regex-posix 22 22 23 - , ghc, gmp 23 + , bootPkgs, gmp 24 24 , jailbreak-cabal 25 25 26 26 , runCommand ··· 41 41 , ghcjsBoot ? import ./ghcjs-boot.nix { inherit fetchgit runCommand; } 42 42 , shims ? import ./shims.nix { inherit fetchFromGitHub; } 43 43 }: 44 - let version = "0.2.0"; in 45 - mkDerivation (rec { 44 + let 45 + inherit (bootPkgs) ghc; 46 + version = "0.2.0"; 47 + 48 + in mkDerivation (rec { 46 49 pname = "ghcjs"; 47 50 inherit version; 48 51 src = fetchFromGitHub { ··· 114 117 --with-gmp-libraries ${gmp}/lib 115 118 ''; 116 119 passthru = { 120 + inherit bootPkgs; 121 + isCross = true; 117 122 isGhcjs = true; 118 - nativeGhc = ghc; 119 123 inherit nodejs ghcjsBoot; 120 124 }; 121 125
-77
pkgs/development/compilers/ghcjs/wrapper.nix
··· 1 - { stdenv, ghc, makeWrapper, coreutils, writeScript }: 2 - let 3 - ghcjs = ghc; 4 - packageDBFlag = "-package-db"; 5 - 6 - GHCGetPackages = writeScript "ghc-get-packages.sh" '' 7 - #! ${stdenv.shell} 8 - # Usage: 9 - # $1: version of GHC 10 - # $2: invocation path of GHC 11 - # $3: prefix 12 - version="$1" 13 - if test -z "$3"; then 14 - prefix="${packageDBFlag} " 15 - else 16 - prefix="$3" 17 - fi 18 - PATH="$PATH:$2" 19 - IFS=":" 20 - for p in $PATH; do 21 - for i in "$p/../share/ghcjs/$system-${ghcjs.version}-${ghcjs.ghc.version}"{,/lib,/ghcjs}"/package.conf.d" "$p/../lib/ghcjs-${ghc.version}_ghc-${ghc.ghc.version}/package.conf.d" ; do 22 - # output takes place here 23 - test -f $i/package.cache && echo -n " $prefix$i" 24 - done 25 - done 26 - ''; 27 - 28 - GHCPackages = writeScript "ghc-packages.sh" '' 29 - #! ${stdenv.shell} -e 30 - declare -A GHC_PACKAGES_HASH # using bash4 hashs to get uniq paths 31 - 32 - for arg in $(${GHCGetPackages} ${ghcjs.version} "$(dirname $0)"); do # Why is ghc.version passed in from here instead of captured in the other script directly? 33 - case "$arg" in 34 - ${packageDBFlag}) ;; 35 - *) 36 - CANONICALIZED="$(${coreutils}/bin/readlink -f -- "$arg")" 37 - GHC_PACKAGES_HASH["$CANONICALIZED"]= ;; 38 - esac 39 - done 40 - 41 - for path in ''${!GHC_PACKAGES_HASH[@]}; do 42 - echo -n "$path:" 43 - done 44 - ''; 45 - in 46 - stdenv.mkDerivation { 47 - name = "ghcjs-ghc${ghcjs.ghc.version}-${ghcjs.version}-wrapper"; 48 - 49 - buildInputs = [makeWrapper]; 50 - propagatedBuildInputs = [ghcjs]; 51 - 52 - unpackPhase = "true"; 53 - installPhase = '' 54 - runHook preInstall 55 - 56 - mkdir -p $out/bin 57 - for prg in ghcjs ; do 58 - makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghcjs.version} \"\$(dirname \$0)\")" 59 - done 60 - for prg in ghcjs-pkg ; do 61 - makeWrapper $ghc/bin/$prg $out/bin/$prg --add-flags "\$(${GHCGetPackages} ${ghcjs.version} \"\$(dirname \$0)\" -${packageDBFlag}=)" 62 - done 63 - 64 - mkdir -p $out/nix-support 65 - ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages 66 - 67 - mkdir -p $out/share/doc 68 - ln -s $ghc/lib $out/lib 69 - ln -s $ghc/share/doc/ghc $out/share/doc/ghc-${ghcjs.version} 70 - 71 - runHook postInstall 72 - ''; 73 - 74 - ghc = ghcjs; 75 - inherit GHCGetPackages GHCPackages; 76 - inherit (ghcjs) meta version; 77 - }
+12 -6
pkgs/development/haskell-modules/generic-builder.nix
··· 56 56 inherit (stdenv.lib) optional optionals optionalString versionOlder 57 57 concatStringsSep enableFeature optionalAttrs toUpper; 58 58 59 + isCross = ghc.isCross or false; 59 60 isGhcjs = ghc.isGhcjs or false; 60 - nativeGhc = if isGhcjs then ghc.nativeGhc else ghc; 61 + packageDbFlag = if isGhcjs || versionOlder "7.6" ghc.version 62 + then "package-db" 63 + else "package-conf"; 64 + 65 + nativeGhc = if isCross then ghc.bootPkgs.ghc else ghc; 66 + nativeIsCross = nativeGhc.isCross or false; 67 + nativePackageDbFlag = if versionOlder "7.6" nativeGhc.version 68 + then "package-db" 69 + else "package-conf"; 61 70 62 71 newCabalFileUrl = "http://hackage.haskell.org/package/${pname}-${version}/revision/${revision}.cabal"; 63 72 newCabalFile = fetchurl { ··· 70 79 import Distribution.Simple 71 80 main = defaultMain 72 81 ''; 73 - 74 - ghc76xOrLater = isGhcjs || stdenv.lib.versionOlder "7.6" ghc.version; 75 - packageDbFlag = if ghc76xOrLater then "package-db" else "package-conf"; 76 82 77 83 hasActiveLibrary = isLibrary && (enableStaticLibraries || enableSharedLibraries || enableLibraryProfiling); 78 84 ··· 97 103 (optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic")) 98 104 (optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests")) 99 105 ] ++ optionals isGhcjs [ 100 - "--with-hsc2hs=${ghc.nativeGhc}/bin/hsc2hs" 106 + "--with-hsc2hs=${nativeGhc}/bin/hsc2hs" 101 107 "--ghcjs" 102 108 ]; 103 109 ··· 125 131 126 132 ghcEnv = ghc.withPackages (p: haskellBuildInputs); 127 133 128 - setupBuilder = if isGhcjs then "${nativeGhc}/bin/ghc" else ghcCommand; 134 + setupBuilder = if isCross then "${nativeGhc}/bin/ghc" else ghcCommand; 129 135 setupCommand = "./Setup"; 130 136 ghcCommand = if isGhcjs then "ghcjs" else "ghc"; 131 137 ghcCommandCaps = toUpper ghcCommand;
+16 -11
pkgs/top-level/haskell-packages.nix
··· 34 34 ghc784 = callPackage ../development/compilers/ghc/7.8.4.nix { 35 35 ghc = compiler.ghc742Binary; 36 36 }; 37 - ghc7102 = callPackage ../development/compilers/ghc/7.10.2.nix { 38 - ghc = compiler.ghc784; inherit (packages.ghc784) hscolour; 37 + ghc7102 = callPackage ../development/compilers/ghc/7.10.2.nix rec { 38 + bootPkgs = packages.ghc784; 39 + inherit (bootPkgs) hscolour; 39 40 }; 40 - ghc7103 = callPackage ../development/compilers/ghc/7.10.3.nix { 41 - ghc = compiler.ghc784; inherit (packages.ghc784) hscolour; 41 + ghc7103 = callPackage ../development/compilers/ghc/7.10.3.nix rec { 42 + bootPkgs = packages.ghc784; 43 + inherit (bootPkgs) hscolour; 42 44 }; 43 - ghc801 = callPackage ../development/compilers/ghc/8.0.1.nix { 44 - ghc = compiler.ghc7103; inherit (packages.ghc7103) hscolour; 45 + ghc801 = callPackage ../development/compilers/ghc/8.0.1.nix rec { 46 + bootPkgs = packages.ghc7103; 47 + inherit (bootPkgs) hscolour; 45 48 }; 46 - ghcHEAD = callPackage ../development/compilers/ghc/head.nix { 47 - inherit (packages.ghc784) ghc alex happy; 49 + ghcHEAD = callPackage ../development/compilers/ghc/head.nix rec { 50 + bootPkgs = packages.ghc784; 51 + inherit (bootPkgs) alex happy; 48 52 }; 49 - ghcNokinds = callPackage ../development/compilers/ghc/nokinds.nix { 50 - inherit (packages.ghc784) ghc alex happy; 53 + ghcNokinds = callPackage ../development/compilers/ghc/nokinds.nix rec { 54 + bootPkgs = packages.ghc784; 55 + inherit (bootPkgs) alex happy; 51 56 }; 52 57 53 58 ghcjs = packages.ghc7103.callPackage ../development/compilers/ghcjs { 54 - ghc = compiler.ghc7103; 59 + bootPkgs = packages.ghc7103; 55 60 }; 56 61 57 62 jhc = callPackage ../development/compilers/jhc {