@@ -461,12 +461,31 @@ let
461
461
in ''
462
462
runHook preInstall
463
463
${ # `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
+ '' }
470
489
${ lib . optionalString ( haskellLib . isLibrary componentId ) ''
471
490
$SETUP_HS register --gen-pkg-config=${ name } .conf
472
491
${ ghc . targetPrefix } ghc-pkg -v0 init $out/package.conf.d
519
538
mkdir -p $out/bin
520
539
if [ -f ${ testExecutable } ]; then
521
540
mkdir -p $(dirname $out/bin/${ exeName } )
541
+ ${ lib . optionalString stdenv . buildPlatform . isLinux "sync" }
522
542
${ if stdenv . hostPlatform . isGhcjs then ''
523
543
cat <(echo \#!${ lib . getBin buildPackages . nodejs-18_x } /bin/node) ${ testExecutable } >| $out/bin/${ exeName }
524
544
chmod +x $out/bin/${ exeName }
0 commit comments