diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index bf1f2c387ad9f..4b7201bb6ac9b 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -11,7 +11,12 @@ let in { pname -, dontStrip ? (ghc.isGhcjs or false) +# Note that ghc.isGhcjs != stdenv.hostPlatform.isGhcjs. +# ghc.isGhcjs implies that we are using ghcjs, a project separate from GHC. +# (mere) stdenv.hostPlatform.isGhcjs means that we are using GHC's JavaScript +# backend. The latter is a normal cross compilation backend and needs little +# special accomodation. +, dontStrip ? (ghc.isGhcjs or false || stdenv.hostPlatform.isGhcjs) , version, revision ? null , sha256 ? null , src ? fetchurl { url = "mirror://hackage/${pname}-${version}.tar.gz"; inherit sha256; } @@ -171,7 +176,7 @@ let # Pass the "wrong" C compiler rather than none at all so packages that just # use the C preproccessor still work, see # https://github.com/haskell/cabal/issues/6466 for details. - "--with-gcc=${(if stdenv.hasCC then stdenv else buildPackages.stdenv).cc.targetPrefix}cc" + "--with-gcc=${if stdenv.hasCC then "$CC" else "$CC_FOR_BUILD"}" ] ++ optionals stdenv.hasCC [ "--with-ld=${stdenv.cc.bintools.targetPrefix}ld" "--with-ar=${stdenv.cc.bintools.targetPrefix}ar" @@ -246,7 +251,10 @@ let allPkgconfigDepends = pkg-configDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++ optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends; - depsBuildBuild = [ nativeGhc ]; + depsBuildBuild = [ nativeGhc ] + # CC_FOR_BUILD may be necessary if we have no C preprocessor for the host + # platform. See crossCabalFlags above for more details. + ++ lib.optionals (!stdenv.hasCC) [ buildPackages.stdenv.cc ]; collectedToolDepends = buildTools ++ libraryToolDepends ++ executableToolDepends ++ optionals doCheck testToolDepends ++ @@ -316,7 +324,9 @@ stdenv.mkDerivation ({ inherit src; inherit depsBuildBuild nativeBuildInputs; - buildInputs = otherBuildInputs ++ optionals (!isLibrary) propagatedBuildInputs; + buildInputs = otherBuildInputs ++ optionals (!isLibrary) propagatedBuildInputs + # For patchShebangsAuto in fixupPhase + ++ optionals stdenv.hostPlatform.isGhcjs [ nodejs ]; propagatedBuildInputs = optionals isLibrary propagatedBuildInputs; LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase. diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8e15d2571837f..9202cb50281a7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14550,10 +14550,13 @@ with pkgs; haskell = callPackage ./haskell-packages.nix { }; haskellPackages = dontRecurseIntoAttrs - # Prefer native-bignum to avoid linking issues with gmp - (if stdenv.hostPlatform.isStatic - then haskell.packages.native-bignum.ghc92 - else haskell.packages.ghc92); + # JS backend is only available for GHC >= 9.6 + (if stdenv.hostPlatform.isGhcjs + then haskell.packages.native-bignum.ghcHEAD + # Prefer native-bignum to avoid linking issues with gmp + else if stdenv.hostPlatform.isStatic + then haskell.packages.native-bignum.ghc92 + else haskell.packages.ghc92); # haskellPackages.ghc is build->host (it exposes the compiler used to build the # set, similarly to stdenv.cc), but pkgs.ghc should be host->target to be more diff --git a/pkgs/top-level/release-cross.nix b/pkgs/top-level/release-cross.nix index 6eeda58a6c172..0acd119991b6b 100644 --- a/pkgs/top-level/release-cross.nix +++ b/pkgs/top-level/release-cross.nix @@ -159,6 +159,8 @@ in /* Javacript */ ghcjs = mapTestOnCross lib.systems.examples.ghcjs { haskell.packages.ghcjs.hello = nativePlatforms; + haskell.packages.native-bignum.ghcHEAD.hello = nativePlatforms; + haskellPackages.hello = nativePlatforms; }; /* Linux on Raspberrypi */ diff --git a/pkgs/top-level/release-haskell.nix b/pkgs/top-level/release-haskell.nix index 94f8352295670..ee7e64f1ffaa8 100644 --- a/pkgs/top-level/release-haskell.nix +++ b/pkgs/top-level/release-haskell.nix @@ -345,6 +345,13 @@ let ; }; }; + + pkgsCross.ghcjs.haskellPackages = { + inherit (packagePlatforms pkgs.pkgsCross.ghcjs.haskellPackages) + ghc + hello + ; + }; }) (versionedCompilerJobs { # Packages which should be checked on more than the