Skip to content

Commit c0af1cc

Browse files
committed
Merge branch 'master' of github.com:input-output-hk/haskell.nix into circuithub
2 parents 4fafa7a + a5a666e commit c0af1cc

File tree

870 files changed

+109685
-1534
lines changed

Some content is hidden

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

870 files changed

+109685
-1534
lines changed

.github/workflows/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ jobs:
225225
steps:
226226
- uses: actions/checkout@v3
227227
- name: "Check that evaluation of hydra jobs works without using remote builders"
228-
run: nix-instantiate release.nix -A x86_64-darwin.required-unstable-ghc8107-native --show-trace --builders ''
228+
run: nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc8107-native --show-trace --builders ''
229229

230230
hix-cabal:
231231
runs-on: [self-hosted, linux]

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ If you find this happening to you, please check that you have followed the
2121
[getting started instructions](https://input-output-hk.github.io/haskell.nix/tutorials/getting-started#setting-up-the-binary-cache) and
2222
consult the corresponding [troubleshooting section](https://input-output-hk.github.io/haskell.nix/troubleshooting#why-am-i-building-ghc).
2323

24-
The troubleshooting documentation also contains some help for other common issues.
25-
Please give it a read before asking on IRC or opening an issue.
26-
27-
If you're still stuck, join the [#haskell.nix](https://www.irccloud.com/invite?channel=%23haskell.nix&hostname=irc.libera.chat&port=6697&ssl=1) channel on [irc.libera.chat](https://libera.chat/), or open an issue.
24+
The troubleshooting documentation also contains some help for other common issues. If you're still stuck open an issue.
2825

2926
## Related repos
3027

build.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ in rec {
2323
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
2424
pkgs.recurseIntoAttrs ({
2525
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
26+
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.6" < 0) {
2627
hlint-latest = tool compiler-nix-name "hlint" {
2728
inherit evalPackages;
2829
version = {
@@ -39,7 +40,7 @@ in rec {
3940
"ghc8107" = "3.4.1";
4041
}.${compiler-nix-name} or "latest";
4142
};
42-
} // pkgs.lib.optionalAttrs (!__elem compiler-nix-name ["ghc941" "ghc942" "ghc943" "ghc944"]) {
43+
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.4" < 0) {
4344
stack = tool compiler-nix-name "stack" { version = "2.9.3"; inherit evalPackages; };
4445
hls-latest = tool compiler-nix-name "haskell-language-server" {
4546
inherit evalPackages;

builder/comp-builder.nix

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs }@defaults:
1+
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs, nonReinstallablePkgs }@defaults:
22
lib.makeOverridable (
33
let self =
44
{ componentId
@@ -82,7 +82,7 @@ let self =
8282
, enableTSanRTS ? false
8383

8484
# LLVM
85-
, useLLVM ? ghc.useLLVM
85+
, useLLVM ? ghc.useLLVM or false
8686
, smallAddressSpace ? false
8787

8888
}@drvArgs:
@@ -162,7 +162,7 @@ let
162162
if configureAllComponents
163163
then ["--enable-tests" "--enable-benchmarks"]
164164
else ["${haskellLib.componentTarget componentId}"]
165-
) ++ [ "$(cat ${configFiles}/configure-flags)"
165+
) ++ [ "$(cat $configFiles/configure-flags)"
166166
] ++ commonConfigureFlags);
167167

168168
# From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one
@@ -180,16 +180,7 @@ let
180180
[ "--with-gcc=${stdenv.cc.targetPrefix}cc"
181181
] ++
182182
# BINTOOLS
183-
(if stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isAndroid # might be better check to see if cc is clang/llvm?
184-
# use gold as the linker on linux to improve link times
185-
then [
186-
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld.gold"
187-
"--ghc-option=-optl-fuse-ld=gold"
188-
"--ld-option=-fuse-ld=gold"
189-
] else [
190-
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
191-
]
192-
) ++ [
183+
[
193184
"--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
194185
"--with-strip=${stdenv.cc.bintools.targetPrefix}strip"
195186
]
@@ -353,9 +344,14 @@ let
353344
config = component;
354345
srcSubDir = cleanSrc.subDir;
355346
srcSubDirPath = cleanSrc.root + cleanSrc.subDir;
356-
inherit configFiles executableToolDepends exeName enableDWARF;
347+
inherit executableToolDepends exeName enableDWARF;
357348
exePath = drv + "/bin/${exeName}";
358-
env = shellWrappers;
349+
env = shellWrappers.drv;
350+
shell = drv.overrideAttrs (attrs: {
351+
pname = nameOnly + "-shell";
352+
inherit (package.identifier) version;
353+
nativeBuildInputs = [shellWrappers.drv] ++ attrs.nativeBuildInputs;
354+
});
359355
profiled = self (drvArgs // { enableLibraryProfiling = true; });
360356
dwarf = self (drvArgs // { enableDWARF = true; });
361357
} // lib.optionalAttrs (haskellLib.isLibrary componentId) ({
@@ -387,19 +383,22 @@ let
387383
# Not sure why pkgconfig needs to be propagatedBuildInputs but
388384
# for gi-gtk-hs it seems to help.
389385
++ map pkgs.lib.getDev (builtins.concatLists pkgconfig)
386+
# These only need to be propagated for library components (otherwise they
387+
# will be in `buildInputs`)
388+
++ lib.optionals (haskellLib.isLibrary componentId) configFiles.libDeps
390389
++ lib.optionals (stdenv.hostPlatform.isWindows)
391-
(lib.flatten component.libs
392-
++ map haskellLib.dependToLib component.depends);
390+
(lib.flatten component.libs);
393391

394-
buildInputs = lib.optionals (!stdenv.hostPlatform.isWindows)
395-
(lib.flatten component.libs
396-
++ map haskellLib.dependToLib component.depends);
392+
buildInputs =
393+
lib.optionals (!haskellLib.isLibrary componentId) configFiles.libDeps
394+
++ lib.optionals (!stdenv.hostPlatform.isWindows)
395+
(lib.flatten component.libs);
397396

398397
nativeBuildInputs =
399-
[shellWrappers buildPackages.removeReferencesTo]
398+
[ghc buildPackages.removeReferencesTo]
400399
++ executableToolDepends;
401400

402-
outputs = ["out" ]
401+
outputs = ["out" "configFiles" "ghc"]
403402
++ (lib.optional enableSeparateDataOutput "data")
404403
++ (lib.optional keepSource "source")
405404
++ (lib.optional writeHieFiles "hie");
@@ -419,6 +418,18 @@ let
419418
'') + commonAttrs.prePatch;
420419

421420
configurePhase = ''
421+
mkdir -p $configFiles
422+
mkdir -p $ghc
423+
wrappedGhc=$ghc
424+
${configFiles.script}
425+
${shellWrappers.script}
426+
''
427+
# Remove any ghc docs pages so nixpkgs does not include them in $out
428+
# (this can result in unwanted dependencies on GHC)
429+
+ ''
430+
rm -rf $wrappedGhc/share/doc $wrappedGhc/share/man $wrappedGhc/share/devhelp/books
431+
PATH=$wrappedGhc/bin:$PATH
432+
422433
runHook preConfigure
423434
echo Configure flags:
424435
printf "%q " ${finalConfigureFlags}
@@ -499,7 +510,7 @@ let
499510
${lib.optionalString (haskellLib.isLibrary componentId) ''
500511
$SETUP_HS register --gen-pkg-config=${name}.conf
501512
${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
502-
${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register ${name}.conf
513+
${ghc.targetPrefix}ghc-pkg -v0 --package-db $configFiles/${configFiles.packageCfgDir} -f $out/package.conf.d register ${name}.conf
503514
504515
mkdir -p $out/exactDep
505516
touch $out/exactDep/configure-flags
@@ -531,6 +542,7 @@ let
531542
if id=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" id --simple-output); then
532543
name=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" name --simple-output)
533544
echo "--dependency=''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
545+
echo "package-id $id" >> $out/envDep
534546
''
535547
# Allow `package-name:sublib-name` to work in `build-depends`
536548
# by adding the same `--dependency` again, but with the package
@@ -626,7 +638,7 @@ let
626638
'';
627639

628640
shellHook = ''
629-
export PATH="${shellWrappers}/bin:$PATH"
641+
export PATH=$ghc/bin:$PATH
630642
${shellHookApplied}
631643
'';
632644
}

builder/default.nix

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs, compiler, inputMap }:
1+
{ pkgs, buildPackages, evalPackages, stdenv, lib, haskellLib, ghc, compiler-nix-name, fetchurl, nonReinstallablePkgs, hsPkgs, compiler, inputMap }:
22

33
let
44
# Builds a single component of a package.
55
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix {
6-
inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs compiler;
6+
inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs compiler nonReinstallablePkgs;
77
};
88

99
haddockBuilder = haskellLib.weakCallPackage pkgs ./haddock-builder.nix {
@@ -44,7 +44,11 @@ let
4444

4545

4646
hoogleLocal = let
47-
nixpkgsHoogle = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
47+
# Use hoogle.nix from at least nixpkgs 22.05
48+
nixpkgs = if lib.versionAtLeast lib.trivial.release "22.05"
49+
then pkgs.path
50+
else pkgs.haskell-nix.sources.nixpkgs-2205;
51+
nixpkgsHoogle = import (nixpkgs + /pkgs/development/haskell-modules/hoogle.nix);
4852
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc8107" "hoogle" {
4953
inherit evalPackages;
5054
version = "5.0.18.3";
@@ -59,11 +63,9 @@ let
5963
else ghc;
6064
inherit packages hoogle;
6165
};
62-
in if lib.versionAtLeast lib.trivial.release "22.05"
63-
then haskellLib.weakCallPackage pkgs nixpkgsHoogle {
64-
inherit haskellPackages;
65-
} (p: p.packages)
66-
else haskellLib.weakCallPackage pkgs nixpkgsHoogle haskellPackages;
66+
in haskellLib.weakCallPackage pkgs nixpkgsHoogle {
67+
inherit haskellPackages;
68+
} (p: p.packages);
6769

6870
# Same as haskellPackages.shellFor in nixpkgs.
6971
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {

builder/ghc-for-component-wrapper.nix

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,42 @@ let
2020
ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;
2121

2222
inherit (configFiles) targetPrefix ghcCommand ghcCommandCaps packageCfgDir;
23-
libDir = "$out/${configFiles.libDir}";
24-
docDir = "$out/share/doc/ghc/html";
23+
libDir = "$wrappedGhc/${configFiles.libDir}";
24+
docDir = "$wrappedGhc/share/doc/ghc/html";
2525
# For musl we can use haddock from the buildGHC
2626
haddock = if stdenv.hostPlatform.isLinux && stdenv.targetPlatform.isMusl && !haskellLib.isNativeMusl
2727
then ghc.buildGHC
2828
else ghc;
2929

30-
in runCommand "${componentName}-${ghc.name}-env" {
31-
preferLocalBuild = true;
32-
passthru = {
33-
inherit (ghc) version meta;
34-
inherit targetPrefix;
35-
baseGhc = ghc;
36-
};
37-
} (
38-
''
30+
script = ''
3931
. ${makeWrapper}/nix-support/setup-hook
4032
4133
''
4234
# Start with a ghc and remove all of the package directories
4335
+ ''
44-
mkdir -p $out/bin
45-
${lndir}/bin/lndir -silent ${ghc} $out
36+
mkdir -p $wrappedGhc/bin
37+
${lndir}/bin/lndir -silent $unwrappedGhc $wrappedGhc
4638
rm -rf ${libDir}/*/
4739
''
4840
# ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
4941
+ ''
50-
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
42+
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
5143
''
5244
# ... and the ghcjs shim's if they are available ...
5345
+ ''
54-
if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ]; then
55-
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ${libDir}
46+
if [ -d $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/shims ]; then
47+
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/shims ${libDir}
5648
fi
5749
''
5850
# ... and node modules ...
5951
+ ''
60-
if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/ghcjs-node ]; then
61-
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/ghcjs-node ${libDir}
52+
if [ -d $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/ghcjs-node ]; then
53+
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/ghcjs-node ${libDir}
6254
fi
6355
''
6456
# Replace the package database with the one from target package config.
6557
+ ''
66-
ln -s ${configFiles}/${packageCfgDir} $out/${packageCfgDir}
58+
ln -s $configFiles/${packageCfgDir} $wrappedGhc/${packageCfgDir}
6759
6860
''
6961
# Set the GHC_PLUGINS environment variable according to the plugins for the component.
@@ -77,9 +69,9 @@ in runCommand "${componentName}-${ghc.name}-env" {
7769
GHC_PLUGINS="["
7870
LIST_PREFIX=""
7971
${builtins.concatStringsSep "\n" (map (plugin: ''
80-
id=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} id --simple-output)
81-
lib_dir=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} dynamic-library-dirs --simple-output)
82-
lib_base=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} hs-libraries --simple-output)
72+
id=$($unwrappedGhc/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} id --simple-output)
73+
lib_dir=$($unwrappedGhc/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} dynamic-library-dirs --simple-output)
74+
lib_base=$($unwrappedGhc/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} hs-libraries --simple-output)
8375
lib="$(echo ''${lib_dir}/lib''${lib_base}*)"
8476
GHC_PLUGINS="''${GHC_PLUGINS}''${LIST_PREFIX}(\"''${lib}\",\"''${id}\",\"${plugin.moduleName}\",["
8577
LIST_PREFIX=""
@@ -103,25 +95,25 @@ in runCommand "${componentName}-${ghc.name}-env" {
10395
# The NIX_ variables are used by the patched Paths_ghc module.
10496
+ ''
10597
for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
106-
if [[ -x "${ghc}/bin/$prg" ]]; then
107-
rm -f $out/bin/$prg
108-
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
98+
if [[ -x "$unwrappedGhc/bin/$prg" ]]; then
99+
rm -f $wrappedGhc/bin/$prg
100+
makeWrapper $unwrappedGhc/bin/$prg $wrappedGhc/bin/$prg \
109101
--add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
110-
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
111-
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
102+
--set "NIX_${ghcCommandCaps}" "$wrappedGhc/bin/${ghcCommand}" \
103+
--set "NIX_${ghcCommandCaps}PKG" "$wrappedGhc/bin/${ghcCommand}-pkg" \
112104
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
113105
--set "GHC_PLUGINS" "$GHC_PLUGINS" \
114106
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
115107
fi
116108
done
117109
118110
for prg in "${targetPrefix}runghc" "${targetPrefix}runhaskell"; do
119-
if [[ -x "${ghc}/bin/$prg" ]]; then
120-
rm -f $out/bin/$prg
121-
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
122-
--add-flags "-f $out/bin/${ghcCommand}" \
123-
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
124-
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
111+
if [[ -x "$unwrappedGhc/bin/$prg" ]]; then
112+
rm -f $wrappedGhc/bin/$prg
113+
makeWrapper $unwrappedGhc/bin/$prg $wrappedGhc/bin/$prg \
114+
--add-flags "-f $wrappedGhc/bin/${ghcCommand}" \
115+
--set "NIX_${ghcCommandCaps}" "$wrappedGhc/bin/${ghcCommand}" \
116+
--set "NIX_${ghcCommandCaps}PKG" "$wrappedGhc/bin/${ghcCommand}-pkg" \
125117
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
126118
--set "GHC_PLUGINS" "$GHC_PLUGINS" \
127119
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
@@ -132,8 +124,8 @@ in runCommand "${componentName}-${ghc.name}-env" {
132124
# Wrap haddock, if the base GHC provides it.
133125
+ ''
134126
if [[ -x "${haddock}/bin/haddock" ]]; then
135-
rm -f $out/bin/haddock
136-
makeWrapper ${haddock}/bin/haddock $out/bin/haddock \
127+
rm -f $wrappedGhc/bin/haddock
128+
makeWrapper ${haddock}/bin/haddock $wrappedGhc/bin/haddock \
137129
--add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
138130
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
139131
fi
@@ -143,12 +135,31 @@ in runCommand "${componentName}-${ghc.name}-env" {
143135
# --global-package-db flag.
144136
+ ''
145137
for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
146-
if [[ -x "${ghc}/bin/$prg" ]]; then
147-
rm -f $out/bin/$prg
148-
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "--global-package-db=$out/${packageCfgDir}"
138+
if [[ -x "$unwrappedGhc/bin/$prg" ]]; then
139+
rm -f $wrappedGhc/bin/$prg
140+
makeWrapper $unwrappedGhc/bin/$prg $wrappedGhc/bin/$prg --add-flags "--global-package-db=$wrappedGhc/${packageCfgDir}"
149141
fi
150142
done
151143
152144
${postInstall}
153-
''
154-
)
145+
'';
146+
147+
drv = runCommand "${componentName}-${ghc.name}-env" {
148+
preferLocalBuild = true;
149+
passthru = {
150+
inherit script targetPrefix;
151+
inherit (ghc) version meta;
152+
};
153+
propagatedBuildInputs = configFiles.libDeps;
154+
nativeBuildInputs = [ghc];
155+
} (''
156+
mkdir -p $out/configFiles
157+
configFiles=$out/configFiles
158+
${configFiles.script}
159+
wrappedGhc=$out
160+
${script}
161+
'');
162+
in {
163+
inherit script drv targetPrefix;
164+
baseGhc = ghc;
165+
}

0 commit comments

Comments
 (0)