on iko/ghcjs-patch-master help sign in
Keep source for component builds (#345)
41b72e1Hamish Mackenzie
builder/comp-builder.nix+12−3
@@ -31,6 +31,7 @@
31, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
31, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
32, doHoogle ? component.doHoogle # Also build a hoogle index
32, doHoogle ? component.doHoogle # Also build a hoogle index
33, hyperlinkSource ? component.doHyperlinkSource # Link documentation to the source code
33, hyperlinkSource ? component.doHyperlinkSource # Link documentation to the source code
34+, keepSource ? component.keepSource # Build from `source` output in the store then delete `dist`
34
35
35# Profiling
36# Profiling
36, enableLibraryProfiling ? component.enableLibraryProfiling
37, enableLibraryProfiling ? component.enableLibraryProfiling
@@ -189,7 +190,8 @@ stdenv.mkDerivation ({
189
190
190 outputs = ["out" ]
191 outputs = ["out" ]
191 ++ (lib.optional enableSeparateDataOutput "data")
192 ++ (lib.optional enableSeparateDataOutput "data")
192− ++ (lib.optional doHaddock' "doc");
193+ ++ (lib.optional doHaddock' "doc")
194+ ++ (lib.optional keepSource "source");
193
195
194 # Phases
196 # Phases
195 preInstallPhases = lib.optional doHaddock' "haddockPhase";
197 preInstallPhases = lib.optional doHaddock' "haddockPhase";
@@ -200,7 +202,12 @@ stdenv.mkDerivation ({
200 ${buildPackages.haskell-nix.haskellPackages.hpack.components.exes.hpack}/bin/hpack
202 ${buildPackages.haskell-nix.haskellPackages.hpack.components.exes.hpack}/bin/hpack
201 '';
203 '';
202
204
203− configurePhase = ''
205+ configurePhase =
206+ (lib.optionalString keepSource ''
207+ cp -r . $source
208+ cd $source
209+ chmod -R +w .
210+ '') + ''
204 runHook preConfigure
211 runHook preConfigure
205 echo Configure flags:
212 echo Configure flags:
206 printf "%q " ${finalConfigureFlags}
213 printf "%q " ${finalConfigureFlags}
@@ -322,7 +329,9 @@ stdenv.mkDerivation ({
322 '')
329 '')
323 }
330 }
324 runHook postInstall
331 runHook postInstall
325− '';
332+ '' + (lib.optionalString keepSource ''
333+ rm -rf dist
334+ '');
326
335
327 shellHook = ''
336 shellHook = ''
328 export PATH="${shellWrappers}/bin:$PATH"
337 export PATH="${shellWrappers}/bin:$PATH"
lib/check.nix+3−5
@@ -12,25 +12,23 @@ in stdenv.mkDerivation ({
12
12
13 # Useing `srcOnly` (rather than getting the `src` via a `drv.passthru`)
13 # Useing `srcOnly` (rather than getting the `src` via a `drv.passthru`)
14 # should correctly apply the patches from `drv` (if any).
14 # should correctly apply the patches from `drv` (if any).
15− src = srcOnly drv;
15+ src = drv.source or (srcOnly drv);
16
16
17 passthru = {
17 passthru = {
18 inherit (drv) identifier config configFiles executableToolDepends cleanSrc env;
18 inherit (drv) identifier config configFiles executableToolDepends cleanSrc env;
19 };
19 };
20
20
21− inherit (drv) meta LANG LC_ALL;
21+ inherit (drv) meta LANG LC_ALL buildInputs nativeBuildInputs;
22
22
23 inherit (component) doCheck doCrossCheck;
23 inherit (component) doCheck doCrossCheck;
24
24
25− phases = ["buildPhase" "checkPhase"];
25+ phases = ["unpackPhase" "buildPhase"];
26
26
27 # If doCheck or doCrossCheck are false we may still build this
27 # If doCheck or doCrossCheck are false we may still build this
28 # component and we want it to quietly succeed.
28 # component and we want it to quietly succeed.
29 buildPhase = ''
29 buildPhase = ''
30 touch $out
30 touch $out
31− '';
32
31
33− checkPhase = ''
34 runHook preCheck
32 runHook preCheck
35
33
36 ${toString component.testWrapper} ${drv}/${drv.installedExe} ${lib.concatStringsSep " " component.testFlags} | tee $out
34 ${toString component.testWrapper} ${drv}/${drv.installedExe} ${lib.concatStringsSep " " component.testFlags} | tee $out
modules/package.nix+14−8
@@ -316,12 +316,18 @@ in {
316 # this is relevant would be to switch from the bool type to
316 # this is relevant would be to switch from the bool type to
317 # something like an anyBool type, which would merge definitions by
317 # something like an anyBool type, which would merge definitions by
318 # returning true if any is true.
318 # returning true if any is true.
319− config.components.all = lib.mkMerge (
319+ config.components.all =
320+ let allComps = haskellLib.getAllComponents config;
321+ in lib.mkMerge (
320− builtins.map (c:
322+ builtins.map (c:
321− # Exclude attributes that are likely to have conflicting definitions
323+ # Exclude attributes that are likely to have conflicting definitions
322− # (a common use case for `all` is in `shellFor` and it only has an
324+ # (a common use case for `all` is in `shellFor` and it only has an
323− # install phase).
325+ # install phase).
324− builtins.removeAttrs c ["preCheck" "postCheck"]
326+ builtins.removeAttrs c ["preCheck" "postCheck" "keepSource"]
325− ) (haskellLib.getAllComponents config)
327+ ) allComps
328+ ) // {
329+ # If any one of the components needs us to keep the source
330+ # then keep it for the `all` component
331+ keepSource = lib.foldl' (x: comp: x || comp.keepSource) false allComps;
326− );
332+ };
327}
333}
modules/plan.nix+5
@@ -153,6 +153,11 @@ let
153 default = (def.profilingDetail or "exported-functions");
153 default = (def.profilingDetail or "exported-functions");
154 };
154 };
155
155
156+ keepSource = mkOption {
157+ type = bool;
158+ default = (def.keepSource or false);
159+ description = "Keep component source in the store in a `source` output";
160+ };
156 };
161 };
157 packageOptions = def: componentOptions def // {
162 packageOptions = def: componentOptions def // {
158 preUnpack = mkOption {
163 preUnpack = mkOption {