Skip to content

Fix datadir for tests and benchmarks #1765

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

Merged
merged 3 commits into from
Oct 31, 2022
Merged
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
31 changes: 25 additions & 6 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,31 @@ let
in ''
runHook preInstall
${ # `Setup copy` does not install tests and benchmarks.
lib.optionalString (!haskellLib.isTest componentId && !haskellLib.isBenchmark componentId) ''
$SETUP_HS copy ${lib.concatStringsSep " " (
setupInstallFlags
++ lib.optional configureAllComponents
(haskellLib.componentTarget componentId)
)}''}
if !haskellLib.isTest componentId && !haskellLib.isBenchmark componentId
then ''
$SETUP_HS copy ${lib.concatStringsSep " " (
setupInstallFlags
++ lib.optional configureAllComponents
(haskellLib.componentTarget componentId)
)}''
else
# However if there are exes or libraries it does copy the datadir.
# So run it, but expect it might complain there was nothing to do.
''
SETUP_ERR=$(mktemp)
if $SETUP_HS copy ${lib.concatStringsSep " " (
setupInstallFlags
++ lib.optional configureAllComponents
(haskellLib.componentTarget componentId)
)} 2> >(tee $SETUP_ERR >&2); then
echo Setup copy success
else
# we assume that if the SETUP_HS command fails and the following line was found in the error
# log, that it was the only error. Hence if we do _not_ find the line, grep will fail and this derivation
# will be marked as failure.
cat $SETUP_ERR | grep 'Error: Setup: No executables and no library found\. Nothing to do\.'
fi
''}
${lib.optionalString (haskellLib.isLibrary componentId) ''
$SETUP_HS register --gen-pkg-config=${name}.conf
${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
Expand Down