Skip to content
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
8 changes: 8 additions & 0 deletions pkgs/development/haskell-modules/configuration-darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,12 @@ self: super: ({
# same
# https://hydra.nixos.org/build/174540882/nixlog/9
jacinda = dontCheck super.jacinda;

# Greater floating point error on x86_64-darwin (!) for some reason
# https://github.com/ekmett/ad/issues/113
ad = overrideCabal (drv: {
testFlags = drv.testFlags or [ ] ++ [
"-p" "!/issue-108/"
];
}) super.ad;
})
7 changes: 5 additions & 2 deletions pkgs/development/haskell-modules/configuration-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,12 @@ self: super: builtins.intersectAttrs super {
preInstall = drv.preInstall or "" + ''
installTargets="install"
installFlagsArray+=(
"BUILDER=:"
"PREFIX="
"DESTDIR=$out"
# Prevent Makefile from calling cabal/Setup again
"BUILDER=:"
# Make Haskell build dependencies available
"GHC=${self.buildHaskellPackages.ghc.targetPrefix}ghc -global-package-db -package-db $setupPackageConfDir"
)
'';
installPhase = null;
Expand Down Expand Up @@ -973,7 +976,7 @@ self: super: builtins.intersectAttrs super {
preCheck = ''
export HOME=$TMPDIR/home
export PATH=$PWD/dist/build/ihaskell:$PATH
export GHC_PACKAGE_PATH=$PWD/dist/package.conf.inplace/:$GHC_PACKAGE_PATH
export NIX_GHC_PACKAGE_PATH_FOR_TEST=$PWD/dist/package.conf.inplace/:$packageConfDir:
'';
}) super.ihaskell;

Expand Down
41 changes: 38 additions & 3 deletions pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,34 @@ let
'';

intermediatesDir = "share/haskell/${ghc.version}/${pname}-${version}/dist";

# This is a script suitable for --test-wrapper of Setup.hs' test command
# (https://cabal.readthedocs.io/en/3.12/setup-commands.html#cmdoption-runhaskell-Setup.hs-test-test-wrapper).
# We use it to set some environment variables that the test suite may need,
# e.g. GHC_PACKAGE_PATH to invoke GHC(i) at runtime with build dependencies
# available. See the comment accompanying checkPhase below on how to customize
# this behavior. We need to use a wrapper script since Cabal forbids setting
# certain environment variables since they can alter GHC's behavior (e.g.
# GHC_PACKAGE_PATH) and cause failures. While building, Cabal will set
# GHC_ENVIRONMENT to make the packages picked at configure time available to
# GHC, but unfortunately not at test time. The test wrapper script will be
# executed after such environment checks, so we can take some liberties which
# is unproblematic since we know our synthetic package db matches what Cabal
# will see at configure time exactly. See also
# <https://github.com/haskell/cabal/issues/7792>.
testWrapperScript = buildPackages.writeShellScript
"haskell-generic-builder-test-wrapper.sh"
''
set -eu

# We expect this to be either empty or set by checkPhase
if [[ -n "''${NIX_GHC_PACKAGE_PATH_FOR_TEST}" ]]; then
export GHC_PACKAGE_PATH="''${NIX_GHC_PACKAGE_PATH_FOR_TEST}"
fi

exec "$@"
'';

in lib.fix (drv:

stdenv.mkDerivation ({
Expand Down Expand Up @@ -528,8 +556,6 @@ stdenv.mkDerivation ({
configurePhase = ''
runHook preConfigure

unset GHC_PACKAGE_PATH # Cabal complains if this variable is set during configure.

echo configureFlags: $configureFlags
${setupCommand} configure $configureFlags 2>&1 | ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log"
${lib.optionalString (!allowInconsistentDependencies) ''
Expand All @@ -538,7 +564,6 @@ stdenv.mkDerivation ({
exit 1
fi
''}
export GHC_PACKAGE_PATH="$packageConfDir:"

runHook postConfigure
'';
Expand All @@ -565,12 +590,22 @@ stdenv.mkDerivation ({
# Run test suite(s) and pass `checkFlags` as well as `checkFlagsArray`.
# `testFlags` are added to `checkFlagsArray` each prefixed with
# `--test-option`, so Cabal passes it to the underlying test suite binary.
#
# We also take care of setting GHC_PACKAGE_PATH during test suite execution,
# so it can run GHC(i) with build dependencies available:
# - If NIX_GHC_PACKAGE_PATH_FOR_TEST is set, it become the value of GHC_PACKAGE_PATH
# while the test suite is executed.
# - If it is empty, it'll be unset during test suite execution.
# - Otherwise GHC_PACKAGE_PATH will have the package db used for configuring
# plus GHC's core packages.
checkPhase = ''
runHook preCheck
checkFlagsArray+=(
"--show-details=streaming"
"--test-wrapper=${testWrapperScript}"
${lib.escapeShellArgs (builtins.map (opt: "--test-option=${opt}") testFlags)}
)
export NIX_GHC_PACKAGE_PATH_FOR_TEST="''${NIX_GHC_PACKAGE_PATH_FOR_TEST:-$packageConfDir:}"
${setupCommand} test ${testTarget} $checkFlags ''${checkFlagsArray:+"''${checkFlagsArray[@]}"}
runHook postCheck
'';
Expand Down