Skip to content

Commit 8552834

Browse files
Try #1437:
2 parents 5ddab9b + 8ebc878 commit 8552834

File tree

6 files changed

+71
-26
lines changed

6 files changed

+71
-26
lines changed

builder/hspkg-builder.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ assert (if ghc.isHaskellNixCompiler or false then true
2323
+ pkgs.lib.optionalString (name != null) (" for " + name)));
2424

2525
let
26-
cabalFile = if revision == null || revision == 0 then null else
26+
# Some packages bundled with GHC are not the same as they are in hackage.
27+
bundledSrc = {
28+
# These are problematic because the hackage versions will not install and are part of LTS.
29+
"ghc902/stm-2.5.0.0" = "/libraries/stm";
30+
"ghc902/filepath-1.4.2.1" = "/libraries/filepath";
31+
}."${compiler-nix-name}/${name}" or null;
32+
src = if bundledSrc == null then pkg.src else ghc.configured-src + bundledSrc;
33+
cabalFile = if revision == null || revision == 0 || bundledSrc != null then null else
2734
fetchurl {
2835
name = "${name}-${toString revision}.cabal";
2936
url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal";
@@ -94,7 +101,8 @@ let
94101
synopsis = null;
95102
license = "MIT";
96103
};
97-
src = null; cleanSrc = buildPackages.runCommand "default-Setup-src" {} ''
104+
src = null;
105+
cleanSrc = buildPackages.runCommand "default-Setup-src" {} ''
98106
mkdir $out
99107
cat ${defaultSetupSrc} > $out/Setup.hs
100108
'';

builder/make-config-files.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
{ identifier, component, fullName, flags ? {}, needsProfiling ? false, enableDWARF ? false, chooseDrv ? drv: drv, nonReinstallablePkgs ? defaults.nonReinstallablePkgs }:
44

55
let
6+
# Sort and remove duplicates from nonReinstallablePkgs.
7+
# That way changes to the order of nonReinstallablePkgs does not require rebuilds.
8+
nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x));
9+
610
ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;
711

812
flagsAndConfig = field: xs: lib.optionalString (xs != []) ''
@@ -93,7 +97,7 @@ let
9397
ghc=${ghc}
9498
${ # Copy over the nonReinstallablePkgs from the global package db.
9599
''
96-
for p in ${lib.concatStringsSep " " nonReinstallablePkgs}; do
100+
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
97101
find $ghc/lib/${ghc.name}/package.conf.d -name $p'*.conf' -exec cp -f {} $out/${packageCfgDir} \;
98102
done
99103
''}
@@ -152,13 +156,13 @@ let
152156
cat $p/exactDep/cabal.config >> $out/cabal.config
153157
''}
154158
done
155-
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs)}; do
159+
for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs')}; do
156160
if [ -e $ghc/envDeps/$p ]; then
157161
cat $ghc/envDeps/$p >> $out/ghc-environment
158162
fi
159163
done
160164
'' + lib.optionalString component.doExactConfig ''
161-
for p in ${lib.concatStringsSep " " nonReinstallablePkgs}; do
165+
for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do
162166
if [ -e $ghc/exactDeps/$p ]; then
163167
cat $ghc/exactDeps/$p/configure-flags >> $out/configure-flags
164168
cat $ghc/exactDeps/$p/cabal.config >> $out/cabal.config

ci.nix

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@
4444
ghc810420210212 = false;
4545
});
4646
systems = nixpkgsName: nixpkgs: compiler-nix-name: nixpkgs.lib.genAttrs (
47-
nixpkgs.lib.filter (v: v != "aarch64-darwin" || (
48-
# aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs
49-
!__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901"]
50-
&& !__elem nixpkgsName ["R2105"])) supportedSystems) (v: v);
47+
nixpkgs.lib.filter (v:
48+
# We have less x86_64-darwin build capacity so build fewer GhC versions and no R2105
49+
(v != "x86_64-darwin" || (
50+
!__elem compiler-nix-name ["ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"]
51+
&& !__elem nixpkgsName ["R2105"]))
52+
&&
53+
# aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs
54+
(v != "aarch64-darwin" || (
55+
!__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"]
56+
&& !__elem nixpkgsName ["R2105"]))) supportedSystems) (v: v);
5157
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name: system:
5258
# We need to use the actual nixpkgs version we're working with here, since the values
5359
# of 'lib.systems.examples' are not understood between all versions

compiler/ghc/default.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ stdenv.mkDerivation (rec {
288288
$i
289289
done
290290
291-
# Save generated files for needed when building ghcjs
291+
# Save generated files for needed when building ghc and ghcjs
292292
mkdir -p $generated/includes/dist-derivedconstants/header
293293
cp includes/dist-derivedconstants/header/GHCConstantsHaskell*.hs \
294294
$generated/includes/dist-derivedconstants/header
@@ -299,6 +299,15 @@ stdenv.mkDerivation (rec {
299299
fi
300300
mkdir -p $generated/compiler/stage2/build
301301
cp compiler/stage2/build/Config.hs $generated/compiler/stage2/build || true
302+
if [[ -f compiler/stage2/build/GHC/Platform/Constants.hs ]]; then
303+
mkdir -p $generated/compiler/stage2/build/GHC/Platform
304+
cp compiler/stage2/build/GHC/Platform/Constants.hs $generated/compiler/stage2/build/GHC/Platform
305+
fi
306+
if [[ -f compiler/stage2/build/GHC/Settings/Config.hs ]]; then
307+
mkdir -p $generated/compiler/stage2/build/GHC/Settings
308+
cp compiler/stage2/build/GHC/Settings/Config.hs $generated/compiler/stage2/build/GHC/Settings
309+
fi
310+
cp compiler/stage2/build/*.hs-incl $generated/compiler/stage2/build || true
302311
mkdir -p $generated/rts/build
303312
cp rts/build/config.hs-incl $generated/rts/build || true
304313

overlays/ghc-packages.nix

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,42 @@ let
106106
in rec {
107107
ghc-boot-packages-src-and-nix = builtins.mapAttrs
108108
(ghcName: ghc: builtins.mapAttrs
109-
(pkgName: dir: rec {
109+
(pkgName: subDir: rec {
110110
src =
111111
# Add in the generated files needed by ghc-boot
112-
if dir == "libraries/ghc-boot"
113-
then final.evalPackages.runCommand "ghc-boot-src" {} ''
114-
cp -Lr ${ghc.passthru.configured-src}/${dir} $out
115-
chmod -R +w $out
116-
cp -Lr ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/* $out/GHC
112+
if subDir == "libraries/ghc-boot"
113+
then final.evalPackages.runCommand "ghc-boot-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } ''
114+
mkdir $out
115+
lndir -silent ${ghc.passthru.configured-src}/${subDir} $out
116+
ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/* $out/GHC
117117
''
118-
else if dir == "compiler"
119-
then final.evalPackages.runCommand "ghc-src" {} ''
120-
cp -Lr ${ghc.passthru.configured-src}/${dir} $out
121-
chmod -R +w $out
122-
if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then
123-
cp -Lr ${ghc.generated}/compiler/stage2/build/Config.hs $out
124-
fi
125-
''
126-
else "${ghc.passthru.configured-src}/${dir}";
118+
else if subDir == "compiler"
119+
then final.haskell-nix.haskellLib.cleanSourceWith {
120+
src = final.evalPackages.runCommand "ghc-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } ''
121+
mkdir $out
122+
lndir -silent ${ghc.passthru.configured-src} $out
123+
if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs ]]; then
124+
ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs $out/libraries/ghc-boot/GHC
125+
fi
126+
if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs ]]; then
127+
ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs $out/libraries/ghc-boot/GHC/Platform
128+
fi
129+
if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then
130+
ln -s ${ghc.generated}/compiler/stage2/build/Config.hs $out/compiler
131+
fi
132+
if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs ]]; then
133+
ln -s ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs $out/compiler/GHC/Platform
134+
fi
135+
if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs ]]; then
136+
ln -s ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs $out/compiler/GHC/Settings
137+
fi
138+
ln -s ${ghc.generated}/includes/dist-derivedconstants/header/* $out/compiler
139+
ln -s ${ghc.generated}/compiler/stage2/build/*.hs-incl $out/compiler
140+
'';
141+
inherit subDir;
142+
includeSiblings = true;
143+
}
144+
else "${ghc.passthru.configured-src}/${subDir}";
127145
nix = callCabal2Nix ghcName "${ghcName}-${pkgName}" src;
128146
}) (ghc-extra-pkgs ghc.version))
129147
final.buildPackages.haskell-nix.compiler;

release.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluating
22
# on a machine with e.g. no way to build the Darwin IFDs you need!
33
{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
4-
, ifdLevel ? 3
4+
, ifdLevel ? 1
55
, checkMaterialization ? false }:
66

77
let

0 commit comments

Comments
 (0)