|
1 | 1 | { stdenv, buildPackages, ghc, lib, pkgconfig, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }: |
2 | 2 |
|
3 | | -{ componentId |
| 3 | +{ allComponent |
| 4 | +, componentId |
4 | 5 | , component |
5 | 6 | , package |
6 | 7 | , name |
|
19 | 20 | , preInstall ? component.preInstall , postInstall ? component.postInstall |
20 | 21 | , preHaddock ? component.preHaddock , postHaddock ? component.postHaddock |
21 | 22 | , shellHook ? "" |
| 23 | +, isDoctest ? component.isDoctest |
22 | 24 |
|
23 | 25 | , dontPatchELF ? component.dontPatchELF |
24 | 26 | , dontStrip ? component.dontStrip |
|
52 | 54 | then "${name}-all" |
53 | 55 | else "${name}-${componentId.ctype}-${componentId.cname}"; |
54 | 56 |
|
55 | | - configFiles = makeConfigFiles { |
56 | | - inherit (package) identifier; |
57 | | - inherit component fullName flags; |
58 | | - }; |
| 57 | + configFiles = |
| 58 | + if isDoctest |
| 59 | + then |
| 60 | + makeConfigFiles { |
| 61 | + inherit (package) identifier; |
| 62 | + component = allComponent; |
| 63 | + inherit fullName flags; |
| 64 | + } |
| 65 | + else |
| 66 | + makeConfigFiles { |
| 67 | + inherit (package) identifier; |
| 68 | + inherit component fullName flags; |
| 69 | + }; |
59 | 70 |
|
60 | 71 | enableFeature = enable: feature: |
61 | 72 | (if enable then "--enable-" else "--disable-") + feature; |
|
64 | 75 |
|
65 | 76 | finalConfigureFlags = lib.concatStringsSep " " ( |
66 | 77 | [ "--prefix=$out" |
67 | | - "${haskellLib.componentTarget componentId}" |
| 78 | + "${haskellLib.componentSetupTarget componentId component}" |
68 | 79 | "$(cat ${configFiles}/configure-flags)" |
69 | 80 | # GHC |
70 | 81 | "--with-ghc=${ghc.targetPrefix}ghc" |
@@ -188,10 +199,11 @@ stdenv.mkDerivation ({ |
188 | 199 |
|
189 | 200 | SETUP_HS = setup + /bin/Setup; |
190 | 201 |
|
191 | | - outputs = ["out" ] |
| 202 | + outputs = ["out"] |
192 | 203 | ++ (lib.optional enableSeparateDataOutput "data") |
193 | 204 | ++ (lib.optional doHaddock' "doc") |
194 | | - ++ (lib.optional keepSource "source"); |
| 205 | + ++ (lib.optional keepSource "source") |
| 206 | + ++ (lib.optional isDoctest "dist"); |
195 | 207 |
|
196 | 208 | # Phases |
197 | 209 | preInstallPhases = lib.optional doHaddock' "haddockPhase"; |
@@ -219,7 +231,7 @@ stdenv.mkDerivation ({ |
219 | 231 | buildPhase = '' |
220 | 232 | runHook preBuild |
221 | 233 | # https://gitlab.haskell.org/ghc/ghc/issues/9221 |
222 | | - $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupGhcOptions)} |
| 234 | + $SETUP_HS build ${haskellLib.componentBuildTarget componentId component} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupGhcOptions)} |
223 | 235 | runHook postBuild |
224 | 236 | ''; |
225 | 237 |
|
@@ -325,7 +337,9 @@ stdenv.mkDerivation ({ |
325 | 337 | '') |
326 | 338 | } |
327 | 339 | runHook postInstall |
328 | | - '' + (lib.optionalString keepSource '' |
| 340 | + '' + (lib.optionalString isDoctest '' |
| 341 | + cp -r dist/ $dist/ |
| 342 | + '') + (lib.optionalString keepSource '' |
329 | 343 | rm -rf dist |
330 | 344 | ''); |
331 | 345 |
|
|
0 commit comments