Skip to content

Commit 582e9ee

Browse files
hamishmackangerman
andauthored
Fix datadir for tests and benchmarks (#1765)
* Fix datadir for tests and benchmarks Broken by #1732 * Update builder/comp-builder.nix Co-authored-by: Moritz Angermann <[email protected]> * Keep stderr on stderr Co-authored-by: Moritz Angermann <[email protected]>
1 parent bd6e4e8 commit 582e9ee

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

builder/comp-builder.nix

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,31 @@ let
461461
in ''
462462
runHook preInstall
463463
${ # `Setup copy` does not install tests and benchmarks.
464-
lib.optionalString (!haskellLib.isTest componentId && !haskellLib.isBenchmark componentId) ''
465-
$SETUP_HS copy ${lib.concatStringsSep " " (
466-
setupInstallFlags
467-
++ lib.optional configureAllComponents
468-
(haskellLib.componentTarget componentId)
469-
)}''}
464+
if !haskellLib.isTest componentId && !haskellLib.isBenchmark componentId
465+
then ''
466+
$SETUP_HS copy ${lib.concatStringsSep " " (
467+
setupInstallFlags
468+
++ lib.optional configureAllComponents
469+
(haskellLib.componentTarget componentId)
470+
)}''
471+
else
472+
# However if there are exes or libraries it does copy the datadir.
473+
# So run it, but expect it might complain there was nothing to do.
474+
''
475+
SETUP_ERR=$(mktemp)
476+
if $SETUP_HS copy ${lib.concatStringsSep " " (
477+
setupInstallFlags
478+
++ lib.optional configureAllComponents
479+
(haskellLib.componentTarget componentId)
480+
)} 2> >(tee $SETUP_ERR >&2); then
481+
echo Setup copy success
482+
else
483+
# we assume that if the SETUP_HS command fails and the following line was found in the error
484+
# log, that it was the only error. Hence if we do _not_ find the line, grep will fail and this derivation
485+
# will be marked as failure.
486+
cat $SETUP_ERR | grep 'Error: Setup: No executables and no library found\. Nothing to do\.'
487+
fi
488+
''}
470489
${lib.optionalString (haskellLib.isLibrary componentId) ''
471490
$SETUP_HS register --gen-pkg-config=${name}.conf
472491
${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d

0 commit comments

Comments
 (0)