Skip to content

Commit 52a0640

Browse files
committed
Merge branch 'master' of github.com:input-output-hk/haskell.nix into circuithub
2 parents ae7528a + a411091 commit 52a0640

File tree

1,683 files changed

+85689
-34061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,683 files changed

+85689
-34061
lines changed

.github/workflows/pipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ jobs:
231231
runs-on: [self-hosted, linux]
232232
steps:
233233
- uses: actions/checkout@v3
234-
- name: "Check hix -- run github:haskell/cabal/3.8#cabal-install:exe:cabal -- --version"
235-
run: "HIX_DIR=$(mktemp -d) nix run .#hix --accept-flake-config -- run github:haskell/cabal/3.8#cabal-install:exe:cabal --accept-flake-config --override-input haskellNix . -- --version"
234+
- name: "Check hix -- run github:haskell/cabal/3.10#cabal-install:exe:cabal -- --version"
235+
run: "HIX_DIR=$(mktemp -d) nix run .#hix --accept-flake-config -- run github:haskell/cabal/3.10#cabal-install:exe:cabal --accept-flake-config --override-input haskellNix . -- --version"
236236

237237
nix-tools-build:
238238
runs-on: [self-hosted, linux]

build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ in rec {
5757
inherit evalPackages;
5858
src = pkgs.haskell-nix.sources."hls-1.10";
5959
};
60-
} // {
60+
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.8" < 0) {
6161
"hls-20" = tool compiler-nix-name "haskell-language-server" {
6262
inherit evalPackages;
6363
src = pkgs.haskell-nix.sources."hls-2.0";

builder/comp-builder.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,12 @@ let
418418

419419
prePatch =
420420
# emcc is very slow if it cannot cache stuff in $HOME
421+
# Newer nixpkgs default the cache dir to nix store path.
422+
# This seems to cause problems as it is not writeable.
423+
# Setting EM_CACHE explicitly avoids this problem.
421424
(lib.optionalString stdenv.hostPlatform.isGhcjs ''
422425
export HOME=$(mktemp -d)
426+
export EM_CACHE=$(mktemp -d)
423427
'') +
424428
(lib.optionalString (!canCleanSource) ''
425429
echo "Cleaning component source not supported, leaving it un-cleaned"
@@ -604,7 +608,10 @@ let
604608
for p in ${lib.concatStringsSep " " ([ libffi gmp ] ++
605609
# Also include C++ and mcfgthreads DLLs for GHC 9.4.1 and newer
606610
lib.optionals (builtins.compareVersions defaults.ghc.version "9.4.1" >= 0)
607-
[ buildPackages.gcc-unwrapped windows.mcfgthreads ])}; do
611+
[ buildPackages.gcc-unwrapped
612+
# Find the versions of mfcgthreads used by stdenv.cc
613+
(pkgs.threadsCrossFor or (x: windows.mfcgthreads) stdenv.cc.version).package
614+
])}; do
608615
find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
609616
done
610617
''

builder/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ let
6464
then pkgs.path
6565
else pkgs.haskell-nix.sources.nixpkgs-2205;
6666
nixpkgsHoogle = import (nixpkgs + /pkgs/development/haskell-modules/hoogle.nix);
67-
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc8107" "hoogle" {
67+
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc928" "hoogle" {
6868
inherit evalPackages;
6969
version = "5.0.18.3";
70-
index-state = pkgs.haskell-nix.internalHackageIndexState;
70+
# index-state = pkgs.haskell-nix.internalHackageIndexState;
71+
index-state = "2023-06-05T00:00:00Z";
7172
}
7273
}:
7374
let

builder/make-config-files.nix

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ let
4848
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
4949
ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
5050
ghcCommandCaps = lib.toUpper ghcCommand';
51-
libDir = ghc.libDir or "lib/${ghcCommand}-${ghc.version}";
51+
libDir = ghc.libDir or
52+
# nixpkgs versions of `ghc` do not have a `.libDir`. So this
53+
# default is for them.
54+
("lib/${ghcCommand}-${ghc.version}"
55+
+ lib.optionalString (__compareVersions ghc.version "9.6.1" >= 0) "/lib");
5256
packageCfgDir = "${libDir}/package.conf.d";
5357

5458
libDeps = haskellLib.uniqueWithName (
@@ -81,9 +85,14 @@ let
8185
find $unwrappedGhc/${packageCfgDir} -name $p'*.conf' -exec cp -f {} $configFiles/${packageCfgDir} \;
8286
done
8387
''}
88+
${ # From GHC 9.6 the nixpkgs ghc derviations now use ${pkgroot} in their `.conf` files.
89+
''
90+
sed -i 's|''${pkgroot}/../../../../|/nix/store/|' $configFiles/${packageCfgDir}/*.conf
91+
sed -i 's|''${pkgroot}|${ghc}/${packageCfgDir}/..|' $configFiles/${packageCfgDir}/*.conf
92+
''}
8493
8594
for l in "''${pkgsHostTarget[@]}"; do
86-
if [ -d "$l/${packageCfgDir}" ]; then
95+
if [ -d "$l/${packageCfgDir}" ] && [[ "$l" != "${ghc}" ]]; then
8796
files=("$l/${packageCfgDir}/"*.conf)
8897
if (( ''${#files[@]} )); then
8998
cp -f "''${files[@]}" $configFiles/${packageCfgDir}

ci.nix

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,31 @@
6666
ghc928 = true;
6767
ghc945 = true;
6868
ghc962 = true;
69+
ghc9820230704 = true;
6970
}));
7071
crossSystems = nixpkgsName: nixpkgs: compiler-nix-name:
7172
# We need to use the actual nixpkgs version we're working with here, since the values
7273
# of 'lib.systems.examples' are not understood between all versions
7374
let lib = nixpkgs.lib;
7475
in lib.optionalAttrs (nixpkgsName == "unstable"
75-
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc962"])
76-
|| (system == "aarch64-linux" && __elem compiler-nix-name ["ghc8107" "ghc962"])
77-
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc962"])
78-
|| (system == "aarch64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc962"])
76+
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
77+
|| (system == "aarch64-linux" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
78+
|| (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
79+
|| (system == "aarch64-darwin" && __elem compiler-nix-name ["ghc8107" "ghc962" "ghc9820230704"])
7980
)) {
8081
inherit (lib.systems.examples) ghcjs;
8182
} // lib.optionalAttrs (nixpkgsName == "unstable"
82-
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc945" "ghc962"])
83+
&& ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc926" "ghc927" "ghc928" "ghc945" "ghc962" "ghc9820230704"])
8384
|| (system == "x86_64-darwin" && __elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
8485
inherit (lib.systems.examples) mingwW64;
85-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc945" "ghc962"]) {
86+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923" "ghc924" "ghc926" "ghc927" "ghc928" "ghc945" "ghc962" "ghc9820230704"]) {
8687
# Musl cross only works on linux
8788
# aarch64 cross only works on linux
8889
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
8990
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927" "ghc928"]) {
9091
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
9192
inherit (lib.systems.examples) aarch64-multiplatform-musl;
92-
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927" "ghc928" "ghc945" "ghc962"]) {
93+
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc927" "ghc928" "ghc945" "ghc962" "ghc9820230704"]) {
9394
inherit (lib.systems.examples) aarch64-multiplatform-musl;
9495
};
9596
isDisabled = d: d.meta.disabled or false;

compiler/ghc/default.nix

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ assert enableNativeBignum -> !enableIntegerSimple;
8686
assert enableIntegerSimple -> !enableNativeBignum;
8787

8888
let
89-
src = src-spec.file or fetchurl { inherit (src-spec) url sha256; };
89+
src = src-spec.file or (fetchurl { inherit (src-spec) url sha256; });
9090

9191
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
9292
inherit (haskell-nix.haskellLib) isCrossTarget;
@@ -202,6 +202,13 @@ let
202202
"--enable-dwarf-unwind"
203203
"--with-libdw-includes=${lib.getDev elfutils}/include"
204204
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
205+
] ++ lib.optionals (targetPlatform.isDarwin && builtins.compareVersions ghc-version "9.6" >= 0) [
206+
# From https://github.com/NixOS/nixpkgs/commit/6454fb1bc0b5884d0c11c98a8a99735ef5a0cae8
207+
# Darwin uses llvm-ar. GHC will try to use `-L` with `ar` when it is `llvm-ar`
208+
# but it doesn’t currently work because Cabal never uses `-L` on Darwin. See:
209+
# https://gitlab.haskell.org/ghc/ghc/-/issues/23188
210+
# https://github.com/haskell/cabal/issues/8882
211+
"fp_cv_prog_ar_supports_dash_l=no"
205212
] ++ lib.optional (targetPlatform.isGhcjs) "--target=javascript-unknown-ghcjs"; # TODO use configurePlatforms once tripple is updated in nixpkgs
206213

207214
# Splicer will pull out correct variations
@@ -241,7 +248,9 @@ let
241248
then ../../materialized/ghc8107/hadrian-ghc92
242249
else if builtins.compareVersions ghc-version "9.6" < 0
243250
then ../../materialized/ghc8107/hadrian-ghc94
244-
else ../../materialized/ghc8107/hadrian-ghc96;
251+
else if builtins.compareVersions ghc-version "9.8" < 0
252+
then ../../materialized/ghc8107/hadrian-ghc96
253+
else ../../materialized/ghc8107/hadrian-ghc98;
245254
modules = [{
246255
# Apply the patches in a way that does not require using something
247256
# like `srcOnly`. The problem with `pkgs.srcOnly` was that it had to run
@@ -342,9 +351,8 @@ stdenv.mkDerivation (rec {
342351
patches = ghc-patches;
343352

344353
# configure was run by configured-src already.
345-
phases = [ "unpackPhase" "patchPhase" ]
346-
++ lib.optional (ghc-patches != [] && !stdenv.targetPlatform.isGhcjs) "autoreconfPhase" # autoreconf can replace config.sub with one that is missing ghcjs
347-
++ [ "configurePhase" "buildPhase"
354+
phases = [ "unpackPhase" "patchPhase" "autoreconfPhase"
355+
"configurePhase" "buildPhase"
348356
"checkPhase" "installPhase"
349357
"fixupPhase"
350358
"installCheckPhase"
@@ -358,11 +366,14 @@ stdenv.mkDerivation (rec {
358366
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
359367
export "''${env#TARGET_}=''${!env}"
360368
done
361-
'' + lib.optionalString (targetPlatform.isGhcjs) ''
369+
''
370+
# Use emscripten and the `config.sub` saved by `postPatch`
371+
+ lib.optionalString (targetPlatform.isGhcjs) ''
362372
export CC="${targetCC}/bin/emcc"
363373
export CXX="${targetCC}/bin/em++"
364374
export LD="${targetCC}/bin/emcc"
365375
export EM_CACHE=$(mktemp -d)
376+
mv config.sub.ghcjs config.sub
366377
''
367378
# GHC is a bit confused on its cross terminology, as these would normally be
368379
# the *host* tools.
@@ -425,8 +436,8 @@ stdenv.mkDerivation (rec {
425436
echo '${ghc-version-date}' > VERSION_DATE
426437
''
427438
# The official ghc 9.2.3 tarball requires booting.
428-
+ lib.optionalString (ghc-version == "9.2.3") ''
429-
./boot
439+
+ lib.optionalString (ghc-version == "9.2.3" || ghc-version == "9.8.20230704") ''
440+
python3 ./boot
430441
'';
431442

432443
configurePlatforms = [ "build" "host" ] ++ lib.optional (!targetPlatform.isGhcjs) "target";
@@ -626,14 +637,18 @@ stdenv.mkDerivation (rec {
626637
mkdir $doc
627638
mkdir $generated
628639
'';
629-
phases = [ "unpackPhase" "patchPhase" ]
630-
++ lib.optional (ghc-patches != []) "autoreconfPhase"
631-
++ [ "configurePhase" "installPhase"];
640+
phases = [ "unpackPhase" "patchPhase" "autoreconfPhase"
641+
"configurePhase" "installPhase"];
632642
} // lib.optionalAttrs useHadrian {
633643
postConfigure = ''
634644
for a in libraries/*/*.cabal.in utils/*/*.cabal.in compiler/ghc.cabal.in; do
635645
${hadrian}/bin/hadrian ${hadrianArgs} "''${a%.*}"
636646
done
647+
'' + lib.optionalString (builtins.compareVersions ghc-version "9.8.1" >= 0) ''
648+
for a in bytearray-access-ops.txt.pp addr-access-ops.txt.pp primops.txt; do
649+
${hadrian}/bin/hadrian ${hadrianArgs} _build/stage0/compiler/build/$a
650+
cp _build/stage0/compiler/build/$a compiler/GHC/Builtin/$a
651+
done
637652
'' + lib.optionalString stdenv.isDarwin ''
638653
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
639654
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib ${libcxxabi}/lib'
@@ -644,6 +659,12 @@ stdenv.mkDerivation (rec {
644659
--replace 'cross-compiling = YES' \
645660
'cross-compiling = NO'
646661
'';
662+
} // lib.optionalAttrs targetPlatform.isGhcjs {
663+
# Backup the config.sub that knows what `ghcjs` is in case
664+
# `autoreconfPhase` replaces it
665+
postPatch = ''
666+
cp config.sub config.sub.ghcjs
667+
'';
647668
});
648669

649670
# Used to detect non haskell-nix compilers (accidental use of nixpkgs compilers can lead to unexpected errors)
@@ -671,6 +692,12 @@ stdenv.mkDerivation (rec {
671692
# Needed for `haddock` to work on source that includes non ASCII chars
672693
LANG = "en_US.UTF-8";
673694
LC_ALL = "en_US.UTF-8";
695+
} // lib.optionalAttrs targetPlatform.isGhcjs {
696+
# Backup the config.sub that knows what `ghcjs` is in case
697+
# `autoreconfPhase` replaces it
698+
postPatch = ''
699+
cp config.sub config.sub.ghcjs
700+
'';
674701
} // lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") {
675702
LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive";
676703
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
@@ -702,6 +729,10 @@ stdenv.mkDerivation (rec {
702729
substituteInPlace rts/win32/ThrIOManager.c --replace rts\\OSThreads.h rts/OSThreads.h
703730
fi
704731
'';
732+
# Same hack as 'preBuild'
733+
preInstall = lib.optionalString stdenv.buildPlatform.isDarwin ''
734+
export XATTR=$(mktemp -d)/nothing
735+
'';
705736
} // lib.optionalAttrs useHadrian {
706737
postConfigure = lib.optionalString stdenv.isDarwin ''
707738
substituteInPlace mk/system-cxx-std-lib-1.0.conf \
@@ -715,7 +746,7 @@ stdenv.mkDerivation (rec {
715746
'';
716747
buildPhase = ''
717748
${hadrian}/bin/hadrian ${hadrianArgs}
718-
'' + lib.optionalString (installStage1 && !stdenv.targetPlatform.isGhcjs) ''
749+
'' + lib.optionalString (installStage1 && !stdenv.targetPlatform.isGhcjs && builtins.compareVersions ghc-version "9.8" < 0) ''
719750
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:libiserv
720751
'' + lib.optionalString targetPlatform.isMusl ''
721752
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:terminfo
@@ -754,6 +785,7 @@ stdenv.mkDerivation (rec {
754785
--replace ',("windres command", "/bin/false")' ',("windres command", "${targetCC.bintools.targetPrefix}windres")'
755786
''
756787
else ''
788+
runHook preInstall
757789
${hadrian}/bin/hadrian ${hadrianArgs} binary-dist-dir
758790
cd _build/bindist/ghc-*
759791
./configure --prefix=$out ${lib.concatStringsSep " " configureFlags}

compiler/ghcjs/ghcjs.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ let
6464
dontInstall = true;
6565
buildPhase = ''
6666
export HOME=$TMP
67+
export EM_CACHE=$(mktemp -d)
6768
mkdir $HOME/.cabal
6869
touch $HOME/.cabal/config
6970
cd lib/boot

flake.lock

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/call-cabal-project-to-nix.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ let
423423
hpack $hpackFile
424424
''
425425
else ''
426-
echo WARNING $hpackFile has no .cabal file and `supportHpack` was not set.
426+
echo "WARNING $hpackFile has no .cabal file and \`supportHpack\` was not set."
427427
''
428428
}
429429
fi

0 commit comments

Comments
 (0)