Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around for packages in lts that do not install. #1437

Merged
merged 15 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 4 additions & 2 deletions modules/component-driver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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 (
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
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;
Expand Down
6 changes: 2 additions & 4 deletions test/setup-deps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
5 changes: 5 additions & 0 deletions test/setup-deps/pkg/Setup.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
import Distribution.Simple

-- https://github.com/snoyberg/conduit#readme
Expand All @@ -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.
Expand Down