mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
Work around for packages in lts that do not install. (#1437)
For ghc 9.0.2 Haskell.nix will use the `stm`and `filepath` source that came with `ghc` when the version desired matches. This is because 9.0.2 shipped with packages that differ from the same version in hackage. `reinstallableLibGhc` is fixed for GHC 8.10 and above. Rather than including a patch file this works by: * Setting the `subDir` to the `compiler` directory when building. That way relative paths to other parts of the `ghc` source tree (outside the `compiler` directory) still work. * Files that are needed, but generated when `ghc` builds are added from the `generated` output of the ghc derivation. `nonReinstallablePkgs` is now sorted and deduplicated before it is used (this reduces the chance of rebuilds when the list is refactored).
This commit is contained in:
parent
c357208f96
commit
f3ea06dcac
@ -23,7 +23,14 @@ assert (if ghc.isHaskellNixCompiler or false then true
|
||||
+ pkgs.lib.optionalString (name != null) (" for " + name)));
|
||||
|
||||
let
|
||||
cabalFile = if revision == null || revision == 0 then null else
|
||||
# Some packages bundled with GHC are not the same as they are in hackage.
|
||||
bundledSrc = {
|
||||
# These are problematic because the hackage versions will not install and are part of LTS.
|
||||
"ghc902/stm-2.5.0.0" = "/libraries/stm";
|
||||
"ghc902/filepath-1.4.2.1" = "/libraries/filepath";
|
||||
}."${compiler-nix-name}/${name}" or null;
|
||||
src = if bundledSrc == null then pkg.src else ghc.configured-src + bundledSrc;
|
||||
cabalFile = if revision == null || revision == 0 || bundledSrc != null then null else
|
||||
fetchurl {
|
||||
name = "${name}-${toString revision}.cabal";
|
||||
url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal";
|
||||
@ -94,7 +101,8 @@ let
|
||||
synopsis = null;
|
||||
license = "MIT";
|
||||
};
|
||||
src = null; cleanSrc = buildPackages.runCommand "default-Setup-src" {} ''
|
||||
src = null;
|
||||
cleanSrc = buildPackages.runCommand "default-Setup-src" {} ''
|
||||
mkdir $out
|
||||
cat ${defaultSetupSrc} > $out/Setup.hs
|
||||
'';
|
||||
|
@ -3,6 +3,10 @@
|
||||
{ identifier, component, fullName, flags ? {}, needsProfiling ? false, enableDWARF ? false, chooseDrv ? drv: drv, nonReinstallablePkgs ? defaults.nonReinstallablePkgs }:
|
||||
|
||||
let
|
||||
# Sort and remove duplicates from nonReinstallablePkgs.
|
||||
# That way changes to the order of nonReinstallablePkgs does not require rebuilds.
|
||||
nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x));
|
||||
|
||||
ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;
|
||||
|
||||
flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
|
||||
@ -93,7 +97,7 @@ let
|
||||
ghc=${ghc}
|
||||
${ # Copy over the nonReinstallablePkgs from the global package db.
|
||||
''
|
||||
for p in ${lib.concatStringsSep " " nonReinstallablePkgs}; do
|
||||
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
|
||||
find $ghc/lib/${ghc.name}/package.conf.d -name $p'*.conf' -exec cp -f {} $out/${packageCfgDir} \;
|
||||
done
|
||||
''}
|
||||
@ -152,13 +156,13 @@ let
|
||||
cat $p/exactDep/cabal.config >> $out/cabal.config
|
||||
''}
|
||||
done
|
||||
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs)}; do
|
||||
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs')}; do
|
||||
if [ -e $ghc/envDeps/$p ]; then
|
||||
cat $ghc/envDeps/$p >> $out/ghc-environment
|
||||
fi
|
||||
done
|
||||
'' + lib.optionalString component.doExactConfig ''
|
||||
for p in ${lib.concatStringsSep " " nonReinstallablePkgs}; do
|
||||
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
|
||||
if [ -e $ghc/exactDeps/$p ]; then
|
||||
cat $ghc/exactDeps/$p/configure-flags >> $out/configure-flags
|
||||
cat $ghc/exactDeps/$p/cabal.config >> $out/cabal.config
|
||||
|
14
ci.nix
14
ci.nix
@ -44,10 +44,16 @@
|
||||
ghc810420210212 = false;
|
||||
});
|
||||
systems = nixpkgsName: nixpkgs: compiler-nix-name: nixpkgs.lib.genAttrs (
|
||||
nixpkgs.lib.filter (v: v != "aarch64-darwin" || (
|
||||
# aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs
|
||||
!__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901"]
|
||||
&& !__elem nixpkgsName ["R2105"])) supportedSystems) (v: v);
|
||||
nixpkgs.lib.filter (v:
|
||||
# We have less x86_64-darwin build capacity so build fewer GhC versions and no R2105
|
||||
(v != "x86_64-darwin" || (
|
||||
!__elem compiler-nix-name ["ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"]
|
||||
&& !__elem nixpkgsName ["R2105"]))
|
||||
&&
|
||||
# aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs
|
||||
(v != "aarch64-darwin" || (
|
||||
!__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"]
|
||||
&& !__elem nixpkgsName ["R2105"]))) supportedSystems) (v: v);
|
||||
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name: system:
|
||||
# We need to use the actual nixpkgs version we're working with here, since the values
|
||||
# of 'lib.systems.examples' are not understood between all versions
|
||||
|
@ -288,7 +288,7 @@ stdenv.mkDerivation (rec {
|
||||
$i
|
||||
done
|
||||
|
||||
# Save generated files for needed when building ghcjs
|
||||
# Save generated files for needed when building ghc and ghcjs
|
||||
mkdir -p $generated/includes/dist-derivedconstants/header
|
||||
cp includes/dist-derivedconstants/header/GHCConstantsHaskell*.hs \
|
||||
$generated/includes/dist-derivedconstants/header
|
||||
@ -299,6 +299,15 @@ stdenv.mkDerivation (rec {
|
||||
fi
|
||||
mkdir -p $generated/compiler/stage2/build
|
||||
cp compiler/stage2/build/Config.hs $generated/compiler/stage2/build || true
|
||||
if [[ -f compiler/stage2/build/GHC/Platform/Constants.hs ]]; then
|
||||
mkdir -p $generated/compiler/stage2/build/GHC/Platform
|
||||
cp compiler/stage2/build/GHC/Platform/Constants.hs $generated/compiler/stage2/build/GHC/Platform
|
||||
fi
|
||||
if [[ -f compiler/stage2/build/GHC/Settings/Config.hs ]]; then
|
||||
mkdir -p $generated/compiler/stage2/build/GHC/Settings
|
||||
cp compiler/stage2/build/GHC/Settings/Config.hs $generated/compiler/stage2/build/GHC/Settings
|
||||
fi
|
||||
cp compiler/stage2/build/*.hs-incl $generated/compiler/stage2/build || true
|
||||
mkdir -p $generated/rts/build
|
||||
cp rts/build/config.hs-incl $generated/rts/build || true
|
||||
|
||||
|
@ -54,7 +54,7 @@ in
|
||||
# without reinstallable-lib:ghc, this is significantly larger.
|
||||
|
||||
config.nonReinstallablePkgs =
|
||||
[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
|
||||
[ "rts" "ghc-prim" "integer-gmp" "integer-simple" "base"
|
||||
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
|
||||
# ghcjs custom packages
|
||||
"ghcjs-prim" "ghcjs-th"
|
||||
@ -72,6 +72,9 @@ in
|
||||
"mtl" "parsec" "process" "text" "time" "transformers"
|
||||
"unix" "xhtml" "terminfo"
|
||||
# "stm"
|
||||
]
|
||||
++ lib.optionals (!config.reinstallableLibGhc || __elem config.compiler.nix-name ["ghc865"]) [
|
||||
"ghc-heap"
|
||||
];
|
||||
|
||||
options.bootPkgs = lib.mkOption {
|
||||
@ -80,7 +83,6 @@ in
|
||||
|
||||
config.bootPkgs = [
|
||||
"rts" "ghc-boot-th"
|
||||
"ghc-heap" # since ghc 8.6.
|
||||
"ghcjs-prim"
|
||||
] ++ lib.optional (!config.reinstallableLibGhc) "ghc"
|
||||
++ lib.optionals (
|
||||
|
@ -106,24 +106,42 @@ let
|
||||
in rec {
|
||||
ghc-boot-packages-src-and-nix = builtins.mapAttrs
|
||||
(ghcName: ghc: builtins.mapAttrs
|
||||
(pkgName: dir: rec {
|
||||
(pkgName: subDir: rec {
|
||||
src =
|
||||
# Add in the generated files needed by ghc-boot
|
||||
if dir == "libraries/ghc-boot"
|
||||
then final.evalPackages.runCommand "ghc-boot-src" {} ''
|
||||
cp -Lr ${ghc.passthru.configured-src}/${dir} $out
|
||||
chmod -R +w $out
|
||||
cp -Lr ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/* $out/GHC
|
||||
if subDir == "libraries/ghc-boot"
|
||||
then final.evalPackages.runCommand "ghc-boot-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } ''
|
||||
mkdir $out
|
||||
lndir -silent ${ghc.passthru.configured-src}/${subDir} $out
|
||||
lndir -silent ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC $out/GHC
|
||||
''
|
||||
else if dir == "compiler"
|
||||
then final.evalPackages.runCommand "ghc-src" {} ''
|
||||
cp -Lr ${ghc.passthru.configured-src}/${dir} $out
|
||||
chmod -R +w $out
|
||||
if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then
|
||||
cp -Lr ${ghc.generated}/compiler/stage2/build/Config.hs $out
|
||||
fi
|
||||
''
|
||||
else "${ghc.passthru.configured-src}/${dir}";
|
||||
else if subDir == "compiler"
|
||||
then final.haskell-nix.haskellLib.cleanSourceWith {
|
||||
src = final.evalPackages.runCommand "ghc-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } ''
|
||||
mkdir $out
|
||||
lndir -silent ${ghc.passthru.configured-src} $out
|
||||
if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs ]]; then
|
||||
ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs $out/libraries/ghc-boot/GHC
|
||||
fi
|
||||
if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs ]]; then
|
||||
ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs $out/libraries/ghc-boot/GHC/Platform
|
||||
fi
|
||||
if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then
|
||||
ln -s ${ghc.generated}/compiler/stage2/build/Config.hs $out/compiler
|
||||
fi
|
||||
if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs ]]; then
|
||||
ln -s ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs $out/compiler/GHC/Platform
|
||||
fi
|
||||
if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs ]]; then
|
||||
ln -s ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs $out/compiler/GHC/Settings
|
||||
fi
|
||||
ln -s ${ghc.generated}/includes/dist-derivedconstants/header/* $out/compiler
|
||||
ln -s ${ghc.generated}/compiler/stage2/build/*.hs-incl $out/compiler
|
||||
'';
|
||||
inherit subDir;
|
||||
includeSiblings = true;
|
||||
}
|
||||
else "${ghc.passthru.configured-src}/${subDir}";
|
||||
nix = callCabal2Nix ghcName "${ghcName}-${pkgName}" src;
|
||||
}) (ghc-extra-pkgs ghc.version))
|
||||
final.buildPackages.haskell-nix.compiler;
|
||||
|
@ -17,15 +17,13 @@ let
|
||||
|
||||
meta = {
|
||||
platforms = platforms.unix;
|
||||
# Building reinstallable lib GHC is broken on 8.10, and we require lib ghc so this won't work with cross-compiling.
|
||||
# We require lib ghc so this won't work with cross-compiling.
|
||||
# Moreover, even building the plan doesn't seem to work in these circumstances.
|
||||
disabled = stdenv.buildPlatform != stdenv.hostPlatform || stdenv.hostPlatform.isMusl || __elem compiler-nix-name ["ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc8107" "ghc810420210212"];
|
||||
disabled = stdenv.buildPlatform != stdenv.hostPlatform || stdenv.hostPlatform.isMusl;
|
||||
};
|
||||
in
|
||||
|
||||
recurseIntoAttrs ({
|
||||
meta.disabled = __elem compiler-nix-name ["ghc901" "ghc902" "ghc921" "ghc922"];
|
||||
|
||||
ifdInputs = {
|
||||
plan-nix = addMetaAttrs meta project.plan-nix;
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE CPP #-}
|
||||
import Distribution.Simple
|
||||
|
||||
-- https://github.com/snoyberg/conduit#readme
|
||||
@ -7,7 +8,11 @@ import System.Directory (removeFile)
|
||||
|
||||
-- Make sure Cabal and ghc were included
|
||||
import Distribution.Package ()
|
||||
#if MIN_VERSION_ghc(9,0,0)
|
||||
import GHC.SysTools.Ar ()
|
||||
#else
|
||||
import Ar ()
|
||||
#endif
|
||||
|
||||
example = do
|
||||
-- Pure operations: summing numbers.
|
||||
|
Loading…
Reference in New Issue
Block a user