git.iko.soy/typeable/nixpkgs
on master help sign in
haskell infra: Fix cross as much as possible without changing hashes
commite92cda161ac9f0f0642536f079e39c482564e75e authorJohn Ericson <John.Ericson@Obsidian.Systems> dateSun 10 Sep 2017, 15:36 (9 years ago) parent63bf7d0
4 files changed+41−30
pkgs/development/haskell-modules/generic-builder.nix+23−15 pkgs/development/haskell-modules/make-package-set.nix+15−10 pkgs/development/haskell-modules/with-packages-wrapper.nix+2−3 pkgs/os-specific/darwin/ghc-standalone-archive/default.nix+1−2
pkgs/development/haskell-modules/generic-builder.nix+23−15
@@ -1,7 +1,14 @@
1−{ stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused
2−, jailbreak-cabal, hscolour, cpphs, nodejs, lib, removeReferencesTo
1+{ stdenv, buildPackages, ghc
2+, jailbreak-cabal, hscolour, cpphs, nodejs
3+, buildPlatform, hostPlatform
34}:
4−let isCross = (ghc.cross or null) != null; in
5+
6+let
7+ isCross = buildPlatform != hostPlatform;
8+ inherit (buildPackages)
9+ fetchurl removeReferencesTo
10+ pkgconfig binutils coreutils gnugrep gnused glibcLocales;
11+in
512
613{ pname
714, dontStrip ? (ghc.isGhcjs or false)
@@ -20,8 +27,8 @@ let isCross = (ghc.cross or null) != null; in
2027, enableLibraryProfiling ? false
2128, enableExecutableProfiling ? false
2229# TODO enable shared libs for cross-compiling
23−, enableSharedExecutables ? !isCross && (((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version))
24−, enableSharedLibraries ? !isCross && (((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version))
30+, enableSharedExecutables ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
31+, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
2532, enableSplitObjs ? null # OBSOLETE, use enableDeadCodeElimination
2633, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
2734, enableStaticLibraries ? true
@@ -53,7 +60,7 @@ let isCross = (ghc.cross or null) != null; in
5360, shellHook ? ""
5461, coreSetup ? false # Use only core packages to build Setup.hs.
5562, useCpphs ? false
56−, hardeningDisable ? lib.optional (ghc.isHaLVM or false) "all"
63+, hardeningDisable ? stdenv.lib.optional (ghc.isHaLVM or false) "all"
5764, enableSeparateDataOutput ? false
5865, enableSeparateDocOutput ? doHaddock
5966} @ args:
@@ -102,11 +109,12 @@ let
102109 enableParallelBuilding = (versionOlder "7.8" ghc.version && !hasActiveLibrary) || versionOlder "8.0.1" ghc.version;
103110
104111 crossCabalFlags = [
105− "--with-ghc=${ghc.cross.config}-ghc"
106− "--with-ghc-pkg=${ghc.cross.config}-ghc-pkg"
107− "--with-gcc=${ghc.cc}"
108− "--with-ld=${ghc.ld}"
112+ "--with-ghc=${ghc.prefix}ghc"
113+ "--with-ghc-pkg=${ghc.prefix}ghc-pkg"
114+ "--with-gcc=${ghc.prefix}cc"
115+ "--with-ld=${ghc.prefix}ld"
109116 "--with-hsc2hs=${nativeGhc}/bin/hsc2hs"
117+ "--with-strip=${binutils}/bin/${ghc.prefix}strip"
110118 ] ++ (if isHaLVM then [] else ["--hsc2hs-options=--cross-compile"]);
111119
112120 crossCabalFlagsString =
@@ -135,7 +143,7 @@ let
135143 ] ++ optionals isGhcjs [
136144 "--ghcjs"
137145 ] ++ optionals isCross ([
138− "--configure-option=--host=${ghc.cross.config}"
146+ "--configure-option=--host=${hostPlatform.config}"
139147 ] ++ crossCabalFlags);
140148
141149 setupCompileFlags = [
@@ -170,8 +178,7 @@ let
170178 setupBuilder = if isCross then "${nativeGhc}/bin/ghc" else ghcCommand;
171179 setupCommand = "./Setup";
172180 ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
173− crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
174− ghcCommand = "${crossPrefix}${ghcCommand'}";
181+ ghcCommand = "${ghc.prefix}${ghcCommand'}";
175182 ghcCommandCaps= toUpper ghcCommand';
176183
177184in
@@ -268,6 +275,8 @@ stdenv.mkDerivation ({
268275 runHook postCompileBuildDriver
269276 '';
270277
278+ inherit configureFlags;
279+
271280 configurePhase = ''
272281 runHook preConfigure
273282
@@ -393,7 +402,6 @@ stdenv.mkDerivation ({
393402// optionalAttrs (postCompileBuildDriver != "") { inherit postCompileBuildDriver; }
394403// optionalAttrs (preUnpack != "") { inherit preUnpack; }
395404// optionalAttrs (postUnpack != "") { inherit postUnpack; }
396−// optionalAttrs (configureFlags != []) { inherit configureFlags; }
397405// optionalAttrs (patches != []) { inherit patches; }
398406// optionalAttrs (patchPhase != "") { inherit patchPhase; }
399407// optionalAttrs (preConfigure != "") { inherit preConfigure; }
@@ -412,5 +420,5 @@ stdenv.mkDerivation ({
412420// optionalAttrs (postFixup != "") { inherit postFixup; }
413421// optionalAttrs (dontStrip) { inherit dontStrip; }
414422// optionalAttrs (hardeningDisable != []) { inherit hardeningDisable; }
415−// optionalAttrs (stdenv.isLinux) { LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
423+// optionalAttrs (buildPlatform.isLinux){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
416424)
pkgs/development/haskell-modules/make-package-set.nix+15−10
@@ -1,7 +1,10 @@
11# This expression takes a file like `hackage-packages.nix` and constructs
22# a full package set out of that.
33
4−{ # package-set used for non-haskell dependencies (all of nixpkgs)
4+{ # package-set used for build tools (all of nixpkgs)
5+ buildPackages
6+
7+, # package-set used for non-haskell dependencies (all of nixpkgs)
58 pkgs
69
710, # stdenv to use for building haskell packages
@@ -28,19 +31,21 @@
2831self:
2932
3033let
34+ inherit (stdenv) buildPlatform hostPlatform;
3135
3236 inherit (stdenv.lib) fix' extends makeOverridable;
3337 inherit (haskellLib) overrideCabal;
3438
39+ buildHaskellPackages = if hostPlatform != buildPlatform
40+ then self.ghc.bootPkgs
41+ else self;
42+
3543 mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
3644 inherit stdenv;
37− inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
38− nodejs = pkgs.nodejs-slim;
39− jailbreak-cabal = if (self.ghc.cross or null) != null
40− then self.ghc.bootPkgs.jailbreak-cabal
41− else self.jailbreak-cabal;
45+ nodejs = buildPackages.nodejs-slim;
46+ inherit (buildHaskellPackages) jailbreak-cabal;
4247 inherit (self) ghc;
43− hscolour = overrideCabal self.hscolour (drv: {
48+ hscolour = overrideCabal buildHaskellPackages.hscolour (drv: {
4449 isLibrary = false;
4550 doHaddock = false;
4651 hyperlinkSource = false; # Avoid depending on hscolour for this build.
@@ -104,13 +109,13 @@ let
104109 haskellSrc2nix = { name, src, sha256 ? null }:
105110 let
106111 sha256Arg = if isNull sha256 then "--sha256=" else ''--sha256="${sha256}"'';
107− in pkgs.stdenv.mkDerivation {
112+ in pkgs.buildPackages.stdenv.mkDerivation {
108113 name = "cabal2nix-${name}";
109− buildInputs = [ pkgs.haskellPackages.cabal2nix ];
114+ nativeBuildInputs = [ pkgs.buildPackages.haskellPackages.cabal2nix ];
110115 preferLocalBuild = true;
111116 phases = ["installPhase"];
112117 LANG = "en_US.UTF-8";
113− LOCALE_ARCHIVE = pkgs.lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
118+ LOCALE_ARCHIVE = pkgs.lib.optionalString buildPlatform.isLinux "${buildPackages.glibcLocales}/lib/locale/locale-archive";
114119 installPhase = ''
115120 export HOME="$TMP"
116121 mkdir -p "$out"
pkgs/development/haskell-modules/with-packages-wrapper.nix+2−3
@@ -36,9 +36,8 @@ let
3636 isHaLVM = ghc.isHaLVM or false;
3737 ghc761OrLater = isGhcjs || isHaLVM || lib.versionOlder "7.6.1" ghc.version;
3838 packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
39− ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
40− crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
41− ghcCommand = "${crossPrefix}${ghcCommand'}";
39+ ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
40+ ghcCommand = "${ghc.prefix}${ghcCommand'}";
4241 ghcCommandCaps= lib.toUpper ghcCommand';
4342 libDir = if isHaLVM then "$out/lib/HaLVM-${ghc.version}" else "$out/lib/${ghcCommand}-${ghc.version}";
4443 docDir = "$out/share/doc/ghc/html";
pkgs/os-specific/darwin/ghc-standalone-archive/default.nix+1−2
@@ -2,8 +2,7 @@
22{ haskellPackages, src, deps ? p : [], name }: let
33 inherit (haskellPackages) ghc ghcWithPackages;
44 with-env = ghcWithPackages deps;
5− crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
6− ghcName = "${crossPrefix}ghc";
5+ ghcName = "${ghc.prefix}ghc";
76in runCommand name { buildInputs = [ with-env cctools ]; } ''
87 mkdir -p $out/lib
98 mkdir -p $out/include