@@ -53,7 +53,7 @@ let self =
53
53
, doHoogle ? component . doHoogle # Also build a hoogle index
54
54
, hyperlinkSource ? component . doHyperlinkSource # Link documentation to the source code
55
55
, quickjump ? component . doQuickjump # Generate an index for interactive documentation navigation
56
- , keepSource ? component . keepSource # Build from `source` output in the store then delete `dist`
56
+ , keepSource ? component . keepSource || configureAllComponents # Build from `source` output in the store then delete `dist`
57
57
, setupHaddockFlags ? component . setupHaddockFlags
58
58
59
59
# Profiling
@@ -83,6 +83,11 @@ let self =
83
83
} @drvArgs :
84
84
85
85
let
86
+ componentForSetup =
87
+ if configureAllComponents
88
+ then allComponent
89
+ else component ;
90
+
86
91
# TODO fix cabal wildcard support so hpack wildcards can be mapped to cabal wildcards
87
92
canCleanSource = ! ( cabal-generator == "hpack" && ! ( package . cleanHpack or false ) ) ;
88
93
# In order to support relative references to other packages we need to use
92
97
# is the sub directory in that root path that contains the package.
93
98
# `cleanSrc.subDir` is used in `prePatch` and `lib/cover.nix`.
94
99
cleanSrc = haskellLib . rootAndSubDir ( if canCleanSource
95
- then haskellLib . cleanCabalComponent package component "${ componentId . ctype } -${ componentId . cname } " src
100
+ then haskellLib . cleanCabalComponent package componentForSetup "${ componentId . ctype } -${ componentId . cname } " src
96
101
else
97
102
# We can clean out the siblings though to at least avoid changes to other packages
98
103
# from triggering a rebuild of this one.
114
119
needsProfiling = enableExecutableProfiling || enableLibraryProfiling ;
115
120
116
121
configFiles = makeConfigFiles {
117
- component =
118
- if configureAllComponents
119
- then allComponent
120
- else component ;
122
+ component = componentForSetup ;
121
123
inherit ( package ) identifier ;
122
124
inherit fullName flags needsProfiling ;
123
125
} ;
@@ -333,15 +335,17 @@ let
333
335
++ ( lib . optional enableSeparateDataOutput "data" )
334
336
++ ( lib . optional keepSource "source" ) ;
335
337
336
- configurePhase =
338
+ prePatch =
337
339
( lib . optionalString ( ! canCleanSource ) ''
338
340
echo "Cleaning component source not supported, leaving it un-cleaned"
339
341
'' ) +
340
342
( lib . optionalString keepSource ''
341
343
cp -r . $source
342
344
cd $source
343
345
chmod -R +w .
344
- '' ) + ''
346
+ '' ) + commonAttrs . prePatch ;
347
+
348
+ configurePhase = ''
345
349
runHook preConfigure
346
350
echo Configure flags:
347
351
printf "%q " ${ finalConfigureFlags }
369
373
target-pkg-and-db = "${ ghc . targetPrefix } ghc-pkg -v0 --package-db $out/package.conf.d" ;
370
374
in ''
371
375
runHook preInstall
372
- $SETUP_HS copy ${ lib . concatStringsSep " " setupInstallFlags }
376
+ $SETUP_HS copy ${ lib . concatStringsSep " " (
377
+ setupInstallFlags
378
+ ++ lib . optional configureAllComponents
379
+ ( haskellLib . componentTarget componentId )
380
+ ) }
373
381
${ lib . optionalString ( haskellLib . isLibrary componentId ) ''
374
382
$SETUP_HS register --gen-pkg-config=${ name } .conf
375
383
${ ghc . targetPrefix } ghc-pkg -v0 init $out/package.conf.d
456
464
'' )
457
465
}
458
466
runHook postInstall
459
- '' + ( lib . optionalString keepSource ''
460
- rm -rf dist
461
- '' ) + ( lib . optionalString ( haskellLib . isTest componentId ) ''
467
+ '' + (
468
+ # Keep just the autogen files and package.conf.inplace package
469
+ # DB (probably empty unless this is a library component).
470
+ # We also have to remove any refernces to $out to avoid
471
+ # circular references.
472
+ if configureAllComponents
473
+ then ''
474
+ mv dist dist-tmp-dir
475
+ mkdir -p dist/build
476
+ mv dist-tmp-dir/build/${ componentId . cname } /autogen dist/build/
477
+ mv dist-tmp-dir/package.conf.inplace dist/
478
+ remove-references-to -t $out dist/build/autogen/*
479
+ rm -rf dist-tmp-dir
480
+ ''
481
+ else lib . optionalString keepSource ''
482
+ rm -rf dist
483
+ ''
484
+ ) + ( lib . optionalString ( haskellLib . isTest componentId ) ''
462
485
echo The test ${ package . identifier . name } .components.tests.${ componentId . cname } was built. To run the test build ${ package . identifier . name } .checks.${ componentId . cname } .
463
486
'' ) ;
464
487
0 commit comments