@@ -15,6 +15,8 @@
1515, preBuild ? null, postBuild ? null
1616, preCheck ? null, postCheck ? null
1717, preInstall ? null, postInstall ? null
18+
19+, doCheck ? componentId.ctype == "test"
1820}:
1921
2022let
@@ -127,9 +129,7 @@ let
127129in stdenv.mkDerivation ({
128130 name = fullName;
129131
130− inherit src;
131−
132− doCheck = componentId.ctype == "test";
132+ inherit src doCheck;
133133
134134 passthru = {
135135 inherit (package) identifier;
@@ -181,30 +181,31 @@ in stdenv.mkDerivation ({
181181 runHook postBuild
182182 '';
183183
184− # Note: Cabal does *not* copy test executables during the `install` phase.
185− # Thus we'll just copy them during the check phase.
186184 checkPhase = ''
187185 runHook preCheck
188− $SETUP_HS test
189− mkdir -p $out/${name}
186+ $SETUP_HS test ${lib.concatStringsSep " " component.setupTestFlags}
190187 cp dist/test/*.log $out/${name}/
191− if [ -f "dist/build/${componentId.cname}/${componentId.cname}" ]; then
192− cp dist/build/${componentId.cname}/${componentId.cname} $out/${name}/
193− fi
194− if [ -f "dist/build/${componentId.cname}/${componentId.cname}.exe" ]; then
195− cp dist/build/${componentId.cname}/${componentId.cname}.exe $out/${name}/
196− fi
197188 runHook postCheck
198189 '';
199190
191+ # Note: Cabal does *not* copy test executables during the `install` phase.
200192 installPhase = ''
201193 runHook preInstall
202− $SETUP_HS copy
194+ $SETUP_HS copy ${lib.concatStringsSep " " component.setupInstallFlags}
203195 ${lib.optionalString (haskellLib.isLibrary componentId) ''
204196 $SETUP_HS register --gen-pkg-config=${name}.conf
205197 ${ghc.targetPrefix}ghc-pkg init $out/package.conf.d
206198 ${ghc.targetPrefix}ghc-pkg --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
207199 ''}
200+ ${lib.optionalString (componentId.ctype == "test") ''
201+ mkdir -p $out/${name}
202+ if [ -f "dist/build/${componentId.cname}/${componentId.cname}" ]; then
203+ cp dist/build/${componentId.cname}/${componentId.cname} $out/${name}/
204+ fi
205+ if [ -f "dist/build/${componentId.cname}/${componentId.cname}.exe" ]; then
206+ cp dist/build/${componentId.cname}/${componentId.cname}.exe $out/${name}/
207+ fi
208+ ''}
208209 runHook postInstall
209210 '';
210211}