Skip to content

Commit 90f9762

Browse files
authored
Remove configFiles and ghc component outputs (input-output-hk#1940)
* Remove `configFiles` and `ghc` component outputs These outputs were added when the derivations that used to provide them were removed (they instead the code that creates them is run in the `configurePhase`). These outputs were added when the derivations that used to provide them were removed (they instead the code that creates them is run in the `configurePhase`). We think we might be better off without theses. They have two drawbacks: * When running `genericBuild` inside a shell they must be created manually (with `export configFile=$(mktemp -d)` and `export ghc=$(mktemp -d)`). * The stop `disallowedReferences` from working (see input-output-hk#1934). * It is probably a non zero overhead to including them in the nix cache. This change also adds `keepConfigFiles` and `keepGhc` that can be used like `keepSource` to allow references to `configFiles` and `ghc` to persist. This is needed by `ghc-paths` and `cabal-doctests` packages.
1 parent c9786c7 commit 90f9762

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

builder/comp-builder.nix

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ let self =
5454
, doHoogle ? component.doHoogle # Also build a hoogle index
5555
, hyperlinkSource ? component.doHyperlinkSource # Link documentation to the source code
5656
, quickjump ? component.doQuickjump # Generate an index for interactive documentation navigation
57+
58+
# Keep the configFiles as a derivation output (otherwise they are in a temp directory)
59+
# We need this for `cabal-doctest` to work, but it is also likely
60+
, keepConfigFiles ? component.keepConfigFiles || configureAllComponents
61+
62+
# Keep the ghc wrapper as a `ghc` derivation output (otherwise it is in a temp directory)
63+
# This is used for the `ghc-paths` package in `modules/configuration.nix`
64+
, keepGhc ? component.keepGhc
65+
5766
, keepSource ? component.keepSource || configureAllComponents # Build from `source` output in the store then delete `dist`
5867
, setupHaddockFlags ? component.setupHaddockFlags
5968

@@ -396,7 +405,9 @@ let
396405
[ghc buildPackages.removeReferencesTo]
397406
++ executableToolDepends;
398407

399-
outputs = ["out" "configFiles" "ghc"]
408+
outputs = ["out"]
409+
++ (lib.optional keepConfigFiles "configFiles")
410+
++ (lib.optional keepGhc "ghc")
400411
++ (lib.optional enableSeparateDataOutput "data")
401412
++ (lib.optional keepSource "source")
402413
++ (lib.optional writeHieFiles "hie");
@@ -415,9 +426,22 @@ let
415426
chmod -R +w .
416427
'') + commonAttrs.prePatch;
417428

418-
configurePhase = ''
419-
mkdir -p $configFiles
420-
mkdir -p $ghc
429+
configurePhase =
430+
(
431+
if keepConfigFiles then ''
432+
mkdir -p $configFiles
433+
''
434+
else ''
435+
configFiles=$(mktemp -d)
436+
''
437+
) + (
438+
if keepGhc then ''
439+
mkdir -p $ghc
440+
''
441+
else ''
442+
ghc=$(mktemp -d)
443+
''
444+
) + ''
421445
wrappedGhc=$ghc
422446
${configFiles.script}
423447
${shellWrappers.script}

modules/configuration-nix.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,8 @@ in {
157157
packages.bitvec.patches = [
158158
(fromUntil "1.1.3.0" "1.1.3.0.1" ../patches/bitvec-gmp-fix.patch)
159159
];
160+
161+
# ghc-paths stores the path of the GHC compiler used to build the component.
162+
# we need to keep it in the store so that it will remain valid.
163+
packages.ghc-paths.components.library.keepGhc = true;
160164
}

modules/package.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,13 @@ in {
355355
# Exclude attributes that are likely to have conflicting definitions
356356
# (a common use case for `all` is in `shellFor` and it only has an
357357
# install phase).
358-
builtins.removeAttrs c ["preCheck" "postCheck" "keepSource"]
358+
builtins.removeAttrs c ["preCheck" "postCheck" "keepConfigFiles" "keepGhc" "keepSource"]
359359
) (lib.filter (c: c.buildable && c.planned) allComps)
360360
) // {
361-
# If any one of the components needs us to keep the source
361+
# If any one of the components needs us to keep one of these
362362
# then keep it for the `all` component
363+
keepConfigFiles = lib.foldl' (x: comp: x || comp.keepConfigFiles) false allComps;
364+
keepGhc = lib.foldl' (x: comp: x || comp.keepGhc) false allComps;
363365
keepSource = lib.foldl' (x: comp: x || comp.keepSource) false allComps;
364366
};
365367
}

modules/plan.nix

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ let
168168
default = (def.profilingDetail or "default");
169169
};
170170

171+
keepConfigFiles = mkOption {
172+
type = bool;
173+
default = (def.keepConfigFiles or false);
174+
description = "Keep component configFiles in the store in a `configFiles` output";
175+
};
176+
177+
keepGhc = mkOption {
178+
type = bool;
179+
default = (def.keepGhc or false);
180+
description = "Keep component wrapped ghc in the store in a `ghc` output";
181+
};
182+
171183
keepSource = mkOption {
172184
type = bool;
173185
default = (def.keepSource or false);

0 commit comments

Comments
 (0)