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

ghc 9.2.7, ghc 9.6.1 and replace old-ghc-nix with nixpkgs ghc #1854

Merged
merged 119 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
f8669c6
Try ghc 9.6.1 alpha
hamishmack Feb 20, 2023
f58ea62
Fixes for ghc 9.6
hamishmack Feb 21, 2023
46d7d3b
Fix internal index state
hamishmack Feb 22, 2023
2d56575
Update materialization
hamishmack Feb 22, 2023
66060e3
Use nixpkgs ghc instead of old-ghc-nix
hamishmack Feb 23, 2023
28499fc
Update more materialization
hamishmack Feb 23, 2023
8f3c667
Update more materialization
hamishmack Feb 23, 2023
7ef0694
Fix rename error
hamishmack Feb 23, 2023
a3ce990
Fix infinite recursion
hamishmack Feb 23, 2023
0fe1aa1
Fixes for hydra eval
hamishmack Feb 23, 2023
a652c1b
Fixes for hydra eval
hamishmack Feb 23, 2023
b914628
Use ghc902 to boot ghc 9.2
hamishmack Feb 23, 2023
f3a46c2
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Feb 23, 2023
5502054
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Feb 26, 2023
28deee0
Use hadrian for ghc 9.2
hamishmack Feb 26, 2023
b083bbd
Materialized files
hamishmack Feb 26, 2023
257f3ac
Fix for hadrian from ghc 9.2
hamishmack Feb 27, 2023
77008cd
Add ghc 9.2.7 and update materialization
hamishmack Feb 28, 2023
a67e9af
Add materialization
hamishmack Feb 28, 2023
49fc575
Add materialization
hamishmack Mar 1, 2023
57e0394
Add materialization
hamishmack Mar 1, 2023
9b5f239
Add materialization
hamishmack Mar 1, 2023
b2a6a49
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 1, 2023
f0c89ab
ifdLevel 1
hamishmack Mar 2, 2023
abbb57c
ifdLevel 2
hamishmack Mar 2, 2023
eab64e2
ifdLevel 3
hamishmack Mar 2, 2023
a9eec3a
ifdLevel 1
hamishmack Mar 2, 2023
bbecc03
More fixes for ghc 9.6.1 alpha
hamishmack Mar 6, 2023
efc328a
Add materialization
hamishmack Mar 6, 2023
95026ab
Add materialization
hamishmack Mar 6, 2023
2d061f9
Add materialization
hamishmack Mar 6, 2023
c26a576
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 6, 2023
74f0d93
ifdLevel 2
hamishmack Mar 6, 2023
95d8e03
Add materialization
hamishmack Mar 6, 2023
b99dd67
Build boot tools (except cabal-install) with nixpkgs ghc
hamishmack Mar 7, 2023
a8b184c
Fixes for compilerSelection
hamishmack Mar 7, 2023
bf30988
Merge combined derivations work
hamishmack Mar 8, 2023
ecf1ce9
Build cabal-install with haskell-nix when necessary
hamishmack Mar 8, 2023
d414b58
ifdLevel 0
hamishmack Mar 8, 2023
18e631e
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 8, 2023
19c2aae
Bump to ghc 9.6.1 alpha 3
hamishmack Mar 8, 2023
4418a7c
Update materialization
hamishmack Mar 9, 2023
afb4bb8
Move materialized dummy-ghc-data onto ghc derivation
hamishmack Mar 9, 2023
9c17820
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 9, 2023
95cbaa0
Update latest ghc 9.2 version
hamishmack Mar 9, 2023
8ce4cb5
Update materialization
hamishmack Mar 9, 2023
3ec9a3b
Fix check materialization script
hamishmack Mar 9, 2023
12a2f53
Update materialization
hamishmack Mar 9, 2023
2d1b809
ifdLevel 1
hamishmack Mar 9, 2023
6a23931
ifdLevel 2
hamishmack Mar 9, 2023
f5c50a0
Fix call-cabal-project-to-nix test
hamishmack Mar 9, 2023
b40b704
Try including all jobs for hydra (not aggregating)
hamishmack Mar 9, 2023
b4dddbd
Fix hls tests
hamishmack Mar 9, 2023
a8b3304
Fix hls tests
hamishmack Mar 9, 2023
9cb9f1c
ifdLevel 3
hamishmack Mar 10, 2023
6af52e7
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 10, 2023
32101ad
Update ghc-packages.nix
angerman Mar 10, 2023
45ad41b
Update overlays/ghc-packages.nix
angerman Mar 10, 2023
5a1d0ca
Only use Cabal from ghc source with 9.6
hamishmack Mar 11, 2023
e5859d8
Updated materialization
hamishmack Mar 11, 2023
f3725b1
Only use Cabal from ghc source with 9.6
hamishmack Mar 11, 2023
fba2882
Test fix
hamishmack Mar 11, 2023
3292d69
Add cabal-install as well.
angerman Mar 12, 2023
9717245
Use Cabal 3.8
hamishmack Mar 12, 2023
40ad1cc
Remove unnecessary constraint
hamishmack Mar 12, 2023
d3de349
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 12, 2023
cc64adb
Try four cabal packages
hamishmack Mar 12, 2023
f6502df
Fix cabal-simple test
hamishmack Mar 12, 2023
71c53a3
Fix compiler-nix-name
hamishmack Mar 12, 2023
620a5aa
Focus tests on new copilers for now
hamishmack Mar 12, 2023
6c3fa47
Fixes for tests that use aeson
hamishmack Mar 12, 2023
83912c5
Exclude cabal from ghc-extra-pkgs-cabal-projects
hamishmack Mar 12, 2023
f223160
Add ghc materialization for ghc 9.2.7 arm cross compilation
hamishmack Mar 12, 2023
17ef430
Fixes for ghc 9.6
hamishmack Mar 12, 2023
6329b77
More materialized files
hamishmack Mar 12, 2023
0c6b625
Add missing commas
hamishmack Mar 12, 2023
830a396
More materialized files
hamishmack Mar 12, 2023
3dfab7f
Add GHC 9.6.1 release
hamishmack Mar 12, 2023
97fa2a2
Add other platforms back
hamishmack Mar 12, 2023
0b759e6
Fix for ghc 9.6.1 and materialized files
hamishmack Mar 13, 2023
461ddef
More materialized files
hamishmack Mar 13, 2023
aec8ad5
More materialized files
hamishmack Mar 13, 2023
255feba
ifdLevel 1
hamishmack Mar 13, 2023
7483df6
Remove ghc-extra-projects-nix from roots
hamishmack Mar 13, 2023
a4d2b99
Fix compiler materialization script
hamishmack Mar 13, 2023
15dead6
More materialized files
hamishmack Mar 13, 2023
8777ddd
ifdLevel 2
hamishmack Mar 13, 2023
45ab39c
ifdLevel 3
hamishmack Mar 13, 2023
3163797
Include workarounds for ghc961
hamishmack Mar 13, 2023
94a96dd
Turn ci for older ghc versions back on
hamishmack Mar 13, 2023
0080fce
Install deriveConstants and genprimopcode along ghc
angerman Mar 13, 2023
7530767
Fix for ghc 9.4
hamishmack Mar 13, 2023
792000c
Check that Setup is copied correctly to $out
hamishmack Mar 13, 2023
2c2f670
ifdLevel 0
hamishmack Mar 13, 2023
368ffc0
ifdLevel 1
hamishmack Mar 13, 2023
6d81a89
ifdLevel 2
hamishmack Mar 13, 2023
827b5db
ifdLevel 3
angerman Mar 14, 2023
b53eda4
Update with-packages
hamishmack Mar 14, 2023
dbadcc7
allow newer shipped pkgs
angerman Mar 14, 2023
0bc22fd
Add component.shell
hamishmack Mar 14, 2023
f22ee1d
Make component.shell work with cd $(mktemp) && genericBuild
hamishmack Mar 14, 2023
4a168e2
Fix with-packages test
hamishmack Mar 14, 2023
f127324
Fix with-packages test
hamishmack Mar 14, 2023
4c5c70e
Skip broken th dll tests
hamishmack Mar 14, 2023
2083736
Fix with-packages test for ghc 9.6
hamishmack Mar 15, 2023
32bb37f
Bump stack version
hamishmack Mar 15, 2023
9f975fe
Skip hlint and hls for ghc 9.6
hamishmack Mar 15, 2023
76fedaf
Fix index-state test
hamishmack Mar 15, 2023
19d1cca
Skip broken tools
hamishmack Mar 15, 2023
3904e13
Fix for dwarf support
hamishmack Mar 15, 2023
8d2bbcc
Add requiredJobs for testing evalPlatform
hamishmack Mar 15, 2023
4a005ff
Add requiredJobs for testing evalPlatform
hamishmack Mar 15, 2023
a528765
Fix for eval test
hamishmack Mar 15, 2023
197e42e
Fix truncate index check
hamishmack Mar 15, 2023
638768b
Merge remote-tracking branch 'origin/master' into hkm/ghc961
hamishmack Mar 15, 2023
099bd53
Test more cross compilation
hamishmack Mar 15, 2023
88db87c
Fix for cabal-install 3.10.1.0
hamishmack Mar 15, 2023
d3fd7ee
Updated materialized files
hamishmack Mar 15, 2023
a15ae51
fix: final.*Platform -> final.stdenv.*Platform. (#1878)
dhess Mar 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: "Check that evaluation of hydra jobs works without using remote builders"
run: nix-instantiate release.nix -A x86_64-darwin.required-unstable-ghc8107-native --show-trace --builders ''
run: nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc8107-native --show-trace --builders ''

hix-cabal:
runs-on: [self-hosted, linux]
Expand Down
3 changes: 2 additions & 1 deletion build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ in rec {
tools = pkgs.lib.optionalAttrs (ifdLevel >= 3) (
pkgs.recurseIntoAttrs ({
cabal-latest = tool compiler-nix-name "cabal" { inherit evalPackages; };
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.6" < 0) {
hlint-latest = tool compiler-nix-name "hlint" {
inherit evalPackages;
version = {
Expand All @@ -39,7 +40,7 @@ in rec {
"ghc8107" = "3.4.1";
}.${compiler-nix-name} or "latest";
};
} // pkgs.lib.optionalAttrs (!__elem compiler-nix-name ["ghc941" "ghc942" "ghc943" "ghc944"]) {
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.4" < 0) {
stack = tool compiler-nix-name "stack" { version = "2.9.3"; inherit evalPackages; };
hls-latest = tool compiler-nix-name "haskell-language-server" {
inherit evalPackages;
Expand Down
49 changes: 35 additions & 14 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs }@defaults:
{ pkgs, stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, haddockBuilder, ghcForComponent, hsPkgs, compiler, runCommand, libffi, gmp, windows, zlib, ncurses, nodejs, nonReinstallablePkgs }@defaults:
lib.makeOverridable (
let self =
{ componentId
Expand Down Expand Up @@ -81,7 +81,7 @@ let self =
, enableTSanRTS ? false

# LLVM
, useLLVM ? ghc.useLLVM
, useLLVM ? ghc.useLLVM or false
, smallAddressSpace ? false

}@drvArgs:
Expand Down Expand Up @@ -161,7 +161,7 @@ let
if configureAllComponents
then ["--enable-tests" "--enable-benchmarks"]
else ["${haskellLib.componentTarget componentId}"]
) ++ [ "$(cat ${configFiles}/configure-flags)"
) ++ [ "$(cat $configFiles/configure-flags)"
] ++ commonConfigureFlags);

# From nixpkgs 20.09, the pkg-config exe has a prefix matching the ghc one
Expand Down Expand Up @@ -343,9 +343,14 @@ let
config = component;
srcSubDir = cleanSrc.subDir;
srcSubDirPath = cleanSrc.root + cleanSrc.subDir;
inherit configFiles executableToolDepends exeName enableDWARF;
inherit executableToolDepends exeName enableDWARF;
exePath = drv + "/bin/${exeName}";
env = shellWrappers;
env = shellWrappers.drv;
shell = drv.overrideAttrs (attrs: {
pname = nameOnly + "-shell";
inherit (package.identifier) version;
nativeBuildInputs = [shellWrappers.drv] ++ attrs.nativeBuildInputs;
});
profiled = self (drvArgs // { enableLibraryProfiling = true; });
dwarf = self (drvArgs // { enableDWARF = true; });
} // lib.optionalAttrs (haskellLib.isLibrary componentId) ({
Expand Down Expand Up @@ -377,19 +382,22 @@ let
# Not sure why pkgconfig needs to be propagatedBuildInputs but
# for gi-gtk-hs it seems to help.
++ map pkgs.lib.getDev (builtins.concatLists pkgconfig)
# These only need to be propagated for library components (otherwise they
# will be in `buildInputs`)
++ lib.optionals (haskellLib.isLibrary componentId) configFiles.libDeps
++ lib.optionals (stdenv.hostPlatform.isWindows)
(lib.flatten component.libs
++ map haskellLib.dependToLib component.depends);
(lib.flatten component.libs);

buildInputs = lib.optionals (!stdenv.hostPlatform.isWindows)
(lib.flatten component.libs
++ map haskellLib.dependToLib component.depends);
buildInputs =
lib.optionals (!haskellLib.isLibrary componentId) configFiles.libDeps
++ lib.optionals (!stdenv.hostPlatform.isWindows)
(lib.flatten component.libs);

nativeBuildInputs =
[shellWrappers buildPackages.removeReferencesTo]
[ghc buildPackages.removeReferencesTo]
++ executableToolDepends;

outputs = ["out" ]
outputs = ["out" "configFiles" "ghc"]
++ (lib.optional enableSeparateDataOutput "data")
++ (lib.optional keepSource "source")
++ (lib.optional writeHieFiles "hie");
Expand All @@ -409,6 +417,18 @@ let
'') + commonAttrs.prePatch;

configurePhase = ''
mkdir -p $configFiles
mkdir -p $ghc
wrappedGhc=$ghc
${configFiles.script}
${shellWrappers.script}
''
# Remove any ghc docs pages so nixpkgs does not include them in $out
# (this can result in unwanted dependencies on GHC)
+ ''
rm -rf $wrappedGhc/share/doc $wrappedGhc/share/man $wrappedGhc/share/devhelp/books
PATH=$wrappedGhc/bin:$PATH

runHook preConfigure
echo Configure flags:
printf "%q " ${finalConfigureFlags}
Expand Down Expand Up @@ -489,7 +509,7 @@ let
${lib.optionalString (haskellLib.isLibrary componentId) ''
$SETUP_HS register --gen-pkg-config=${name}.conf
${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register ${name}.conf
${ghc.targetPrefix}ghc-pkg -v0 --package-db $configFiles/${configFiles.packageCfgDir} -f $out/package.conf.d register ${name}.conf

mkdir -p $out/exactDep
touch $out/exactDep/configure-flags
Expand Down Expand Up @@ -521,6 +541,7 @@ let
if id=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" id --simple-output); then
name=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" name --simple-output)
echo "--dependency=''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
echo "package-id $id" >> $out/envDep
''
# Allow `package-name:sublib-name` to work in `build-depends`
# by adding the same `--dependency` again, but with the package
Expand Down Expand Up @@ -616,7 +637,7 @@ let
'';

shellHook = ''
export PATH="${shellWrappers}/bin:$PATH"
export PATH=$ghc/bin:$PATH
${shellHookApplied}
'';
}
Expand Down
16 changes: 9 additions & 7 deletions builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let
# Builds a single component of a package.
comp-builder = haskellLib.weakCallPackage pkgs ./comp-builder.nix {
inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs compiler;
inherit ghc haskellLib makeConfigFiles haddockBuilder ghcForComponent hsPkgs compiler nonReinstallablePkgs;
};

haddockBuilder = haskellLib.weakCallPackage pkgs ./haddock-builder.nix {
Expand Down Expand Up @@ -44,7 +44,11 @@ let


hoogleLocal = let
nixpkgsHoogle = import (pkgs.path + /pkgs/development/haskell-modules/hoogle.nix);
# Use hoogle.nix from at least nixpkgs 22.05
nixpkgs = if lib.versionAtLeast lib.trivial.release "22.05"
then pkgs.path
else pkgs.haskell-nix.sources.nixpkgs-2205;
nixpkgsHoogle = import (nixpkgs + /pkgs/development/haskell-modules/hoogle.nix);
in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.tool "ghc8107" "hoogle" {
inherit evalPackages;
version = "5.0.18.3";
Expand All @@ -59,11 +63,9 @@ let
else ghc;
inherit packages hoogle;
};
in if lib.versionAtLeast lib.trivial.release "22.05"
then haskellLib.weakCallPackage pkgs nixpkgsHoogle {
inherit haskellPackages;
} (p: p.packages)
else haskellLib.weakCallPackage pkgs nixpkgsHoogle haskellPackages;
in haskellLib.weakCallPackage pkgs nixpkgsHoogle {
inherit haskellPackages;
} (p: p.packages);

# Same as haskellPackages.shellFor in nixpkgs.
shellFor = haskellLib.weakCallPackage pkgs ./shell-for.nix {
Expand Down
91 changes: 51 additions & 40 deletions builder/ghc-for-component-wrapper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,42 @@ let
ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;

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

in runCommand "${componentName}-${ghc.name}-env" {
preferLocalBuild = true;
passthru = {
inherit (ghc) version meta;
inherit targetPrefix;
baseGhc = ghc;
};
} (
''
script = ''
. ${makeWrapper}/nix-support/setup-hook

''
# Start with a ghc and remove all of the package directories
+ ''
mkdir -p $out/bin
${lndir}/bin/lndir -silent ${ghc} $out
mkdir -p $wrappedGhc/bin
${lndir}/bin/lndir -silent $unwrappedGhc $wrappedGhc
rm -rf ${libDir}/*/
''
# ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
+ ''
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
''
# ... and the ghcjs shim's if they are available ...
+ ''
if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ]; then
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ${libDir}
if [ -d $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/shims ]; then
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/shims ${libDir}
fi
''
# ... and node modules ...
+ ''
if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/ghcjs-node ]; then
ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/ghcjs-node ${libDir}
if [ -d $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/ghcjs-node ]; then
ln -s $unwrappedGhc/lib/${ghcCommand}-${ghc.version}/ghcjs-node ${libDir}
fi
''
# Replace the package database with the one from target package config.
+ ''
ln -s ${configFiles}/${packageCfgDir} $out/${packageCfgDir}
ln -s $configFiles/${packageCfgDir} $wrappedGhc/${packageCfgDir}

''
# Set the GHC_PLUGINS environment variable according to the plugins for the component.
Expand All @@ -77,9 +69,9 @@ in runCommand "${componentName}-${ghc.name}-env" {
GHC_PLUGINS="["
LIST_PREFIX=""
${builtins.concatStringsSep "\n" (map (plugin: ''
id=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} id --simple-output)
lib_dir=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} dynamic-library-dirs --simple-output)
lib_base=$(${ghc}/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} hs-libraries --simple-output)
id=$($unwrappedGhc/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} id --simple-output)
lib_dir=$($unwrappedGhc/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} dynamic-library-dirs --simple-output)
lib_base=$($unwrappedGhc/bin/ghc-pkg --package-db ${plugin.library}/package.conf.d field ${plugin.library.package.identifier.name} hs-libraries --simple-output)
lib="$(echo ''${lib_dir}/lib''${lib_base}*)"
GHC_PLUGINS="''${GHC_PLUGINS}''${LIST_PREFIX}(\"''${lib}\",\"''${id}\",\"${plugin.moduleName}\",["
LIST_PREFIX=""
Expand All @@ -103,25 +95,25 @@ in runCommand "${componentName}-${ghc.name}-env" {
# The NIX_ variables are used by the patched Paths_ghc module.
+ ''
for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
if [[ -x "${ghc}/bin/$prg" ]]; then
rm -f $out/bin/$prg
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
if [[ -x "$unwrappedGhc/bin/$prg" ]]; then
rm -f $wrappedGhc/bin/$prg
makeWrapper $unwrappedGhc/bin/$prg $wrappedGhc/bin/$prg \
--add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
--set "NIX_${ghcCommandCaps}" "$wrappedGhc/bin/${ghcCommand}" \
--set "NIX_${ghcCommandCaps}PKG" "$wrappedGhc/bin/${ghcCommand}-pkg" \
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
--set "GHC_PLUGINS" "$GHC_PLUGINS" \
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
fi
done

for prg in "${targetPrefix}runghc" "${targetPrefix}runhaskell"; do
if [[ -x "${ghc}/bin/$prg" ]]; then
rm -f $out/bin/$prg
makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
--add-flags "-f $out/bin/${ghcCommand}" \
--set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
--set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
if [[ -x "$unwrappedGhc/bin/$prg" ]]; then
rm -f $wrappedGhc/bin/$prg
makeWrapper $unwrappedGhc/bin/$prg $wrappedGhc/bin/$prg \
--add-flags "-f $wrappedGhc/bin/${ghcCommand}" \
--set "NIX_${ghcCommandCaps}" "$wrappedGhc/bin/${ghcCommand}" \
--set "NIX_${ghcCommandCaps}PKG" "$wrappedGhc/bin/${ghcCommand}-pkg" \
--set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
--set "GHC_PLUGINS" "$GHC_PLUGINS" \
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
Expand All @@ -132,8 +124,8 @@ in runCommand "${componentName}-${ghc.name}-env" {
# Wrap haddock, if the base GHC provides it.
+ ''
if [[ -x "${haddock}/bin/haddock" ]]; then
rm -f $out/bin/haddock
makeWrapper ${haddock}/bin/haddock $out/bin/haddock \
rm -f $wrappedGhc/bin/haddock
makeWrapper ${haddock}/bin/haddock $wrappedGhc/bin/haddock \
--add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
--set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
fi
Expand All @@ -143,12 +135,31 @@ in runCommand "${componentName}-${ghc.name}-env" {
# --global-package-db flag.
+ ''
for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
if [[ -x "${ghc}/bin/$prg" ]]; then
rm -f $out/bin/$prg
makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "--global-package-db=$out/${packageCfgDir}"
if [[ -x "$unwrappedGhc/bin/$prg" ]]; then
rm -f $wrappedGhc/bin/$prg
makeWrapper $unwrappedGhc/bin/$prg $wrappedGhc/bin/$prg --add-flags "--global-package-db=$wrappedGhc/${packageCfgDir}"
fi
done

${postInstall}
''
)
'';

drv = runCommand "${componentName}-${ghc.name}-env" {
preferLocalBuild = true;
passthru = {
inherit script targetPrefix;
inherit (ghc) version meta;
};
propagatedBuildInputs = configFiles.libDeps;
nativeBuildInputs = [ghc];
} (''
mkdir -p $out/configFiles
configFiles=$out/configFiles
${configFiles.script}
wrappedGhc=$out
${script}
'');
in {
inherit script drv targetPrefix;
baseGhc = ghc;
}
25 changes: 15 additions & 10 deletions builder/haddock-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let
finalConfigureFlags = lib.concatStringsSep " " (
[ "--prefix=${componentDrv}"
"${haskellLib.componentTarget componentId}"
"$(cat ${docsConfigFiles}/configure-flags)"
"$(cat $configFiles/configure-flags)"
]
++ commonConfigureFlags
++ lib.optional doHaddock' " --docdir=${docdir "$doc"}");
Expand All @@ -62,28 +62,33 @@ let
name = fullName;

passthru = {
configFiles = docsConfigFiles;

# The directory containing the haddock documentation.
haddockDir = if doHaddock' then "${docdir drv.doc}/html" else null;
haddockDir = lib.const (if doHaddock' then "${docdir drv.doc}/html" else null);
};

# `out` contains the `package.conf.d` files used for building the
# haddock files.
# `doc` contains just the haddock output files.
outputs = ["out"]
outputs = ["out" "configFiles" "ghc"]
++ lib.optional doHaddock' "doc";

propagatedBuildInputs = builtins.concatLists pkgconfig;
propagatedBuildInputs =
builtins.concatLists pkgconfig
++ configFiles.libDeps;

buildInputs = component.libs
++ map (d: d.components.library.haddock or d) component.depends;
buildInputs = component.libs;

nativeBuildInputs =
[ shellWrappers buildPackages.removeReferencesTo ]
[ ghc buildPackages.removeReferencesTo ]
++ componentDrv.executableToolDepends;

configurePhase = ''
mkdir -p $configFiles
mkdir -p $ghc
wrappedGhc=$ghc
${docsConfigFiles.script}
${shellWrappers.script}
PATH=$wrappedGhc/bin:$PATH
runHook preConfigure
echo Configure flags:
printf "%q " ${finalConfigureFlags}
Expand Down Expand Up @@ -144,7 +149,7 @@ let
# working hyper links.
pkg=$(basename "$i")
sed -e "s|haddock-interfaces:.*|haddock-interfaces: $docdir/html/${componentId.cname}.haddock|" -e "s|haddock-html:.*|haddock-html: $docdir/html/|" "$i" > "$pkg"
${ghc.targetPrefix}ghc-pkg -v0 --package-db ${docsConfigFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
${ghc.targetPrefix}ghc-pkg -v0 --package-db $configFiles/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
done

ln -s ${componentDrv}/exactDep $out/exactDep
Expand Down
Loading