Skip to content

Commit

Permalink
Try #1437:
Browse files Browse the repository at this point in the history
  • Loading branch information
iohk-bors[bot] authored Apr 15, 2022
2 parents 5ddab9b + 8ebc878 commit 8552834
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 26 deletions.
12 changes: 10 additions & 2 deletions builder/hspkg-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
'';
Expand Down
10 changes: 7 additions & 3 deletions builder/make-config-files.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 != []) ''
Expand Down Expand Up @@ -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
''}
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
48 changes: 33 additions & 15 deletions overlays/ghc-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
ln -s ${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;
Expand Down
2 changes: 1 addition & 1 deletion release.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluating
# on a machine with e.g. no way to build the Darwin IFDs you need!
{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
, ifdLevel ? 3
, ifdLevel ? 1
, checkMaterialization ? false }:

let
Expand Down

0 comments on commit 8552834

Please sign in to comment.