on iko/ghcjs-patch-master help sign in
Move copy logic from test to install
34bf8d2Moritz Angermann
builder/comp-builder.nix+15−14
@@ -15,6 +15,8 @@
15, preBuild ? null, postBuild ? null
15, preBuild ? null, postBuild ? null
16, preCheck ? null, postCheck ? null
16, preCheck ? null, postCheck ? null
17, preInstall ? null, postInstall ? null
17, preInstall ? null, postInstall ? null
18+
19+, doCheck ? componentId.ctype == "test"
18}:
20}:
19
21
20let
22let
@@ -127,9 +129,7 @@ let
127in stdenv.mkDerivation ({
129in stdenv.mkDerivation ({
128 name = fullName;
130 name = fullName;
129
131
130− inherit src;
132+ inherit src doCheck;
131−
132− doCheck = componentId.ctype == "test";
133
133
134 passthru = {
134 passthru = {
135 inherit (package) identifier;
135 inherit (package) identifier;
@@ -181,30 +181,31 @@ in stdenv.mkDerivation ({
181 runHook postBuild
181 runHook postBuild
182 '';
182 '';
183
183
184− # Note: Cabal does *not* copy test executables during the `install` phase.
185− # Thus we'll just copy them during the check phase.
186 checkPhase = ''
184 checkPhase = ''
187 runHook preCheck
185 runHook preCheck
188− $SETUP_HS test
186+ $SETUP_HS test ${lib.concatStringsSep " " component.setupTestFlags}
189− mkdir -p $out/${name}
190 cp dist/test/*.log $out/${name}/
187 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
197 runHook postCheck
188 runHook postCheck
198 '';
189 '';
199
190
191+ # Note: Cabal does *not* copy test executables during the `install` phase.
200 installPhase = ''
192 installPhase = ''
201 runHook preInstall
193 runHook preInstall
202− $SETUP_HS copy
194+ $SETUP_HS copy ${lib.concatStringsSep " " component.setupInstallFlags}
203 ${lib.optionalString (haskellLib.isLibrary componentId) ''
195 ${lib.optionalString (haskellLib.isLibrary componentId) ''
204 $SETUP_HS register --gen-pkg-config=${name}.conf
196 $SETUP_HS register --gen-pkg-config=${name}.conf
205 ${ghc.targetPrefix}ghc-pkg init $out/package.conf.d
197 ${ghc.targetPrefix}ghc-pkg init $out/package.conf.d
206 ${ghc.targetPrefix}ghc-pkg --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
198 ${ghc.targetPrefix}ghc-pkg --package-db ${configFiles}/package.conf.d -f $out/package.conf.d register ${name}.conf
207 ''}
199 ''}
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+ ''}
208 runHook postInstall
209 runHook postInstall
209 '';
210 '';
210}
211}
modules/package.nix+16
@@ -127,6 +127,14 @@ in {
127 type = listOfFilteringNulls str;
127 type = listOfFilteringNulls str;
128 default = config.setupBuildFlags;
128 default = config.setupBuildFlags;
129 };
129 };
130+ setupTestFlags = mkOption {
131+ type = listOfFilteringNulls str;
132+ default = config.setupTestFlags;
133+ };
134+ setupInstallFlags = mkOption {
135+ type = listOfFilteringNulls str;
136+ default = config.setupInstallFlags;
137+ };
130 doExactConfig = mkOption {
138 doExactConfig = mkOption {
131 type = bool;
139 type = bool;
132 default = false;
140 default = false;
@@ -189,6 +197,14 @@ in {
189 type = listOfFilteringNulls str;
197 type = listOfFilteringNulls str;
190 default = [];
198 default = [];
191 };
199 };
200+ setupTestFlags = mkOption {
201+ type = listOfFilteringNulls str;
202+ default = [];
203+ };
204+ setupInstallFlags = mkOption {
205+ type = listOfFilteringNulls str;
206+ default = [];
207+ };
192 preUnpack = mkOption {
208 preUnpack = mkOption {
193 type = nullOr lines;
209 type = nullOr lines;
194 default = null;
210 default = null;