Skip to content

Commit de1dd86

Browse files
committed
Make the compilerDeps (hadrian plan-nix) on demand.
1 parent 0fb5e56 commit de1dd86

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

build.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ in rec {
2626
} // pkgs.lib.optionalAttrs (ghcFromTo "9.13" "9.14") {
2727
cabalProjectLocal = builtins.readFile ./test/cabal.project.local;
2828
});
29+
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.4" >= 0) {
30+
# Make sure the plan for hadrian is cached (we need it to instanciate ghc).
31+
hadrian-plan = pkgs.haskell-nix.compiler.${compiler-nix-name}.hadrian.project.plan-nix;
32+
# Also include the same plan evaluated on the eval system (probably x86_64-linux).
33+
hadrian-plan-eval = (pkgs.haskell-nix.compiler.${compiler-nix-name}.override { hadrianEvalPackages = evalPackages; }).hadrian.project.plan-nix;
2934
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.8" < 0) {
3035
hlint-latest = tool compiler-nix-name "hlint" {
3136
inherit evalPackages;

compiler/ghc/default.nix

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ let self =
8585

8686
# extra values we want to have available as passthru values.
8787
, extra-passthru ? {}
88+
89+
, hadrianEvalPackages ? buildPackages
8890
}@args:
8991

9092
assert !(enableIntegerSimple || enableNativeBignum) -> gmp != null;
@@ -262,6 +264,7 @@ let
262264
buildPackages.haskell-nix.tool compiler-nix-name "hadrian" {
263265
compilerSelection = p: p.haskell.compiler;
264266
index-state = buildPackages.haskell-nix.internalHackageIndexState;
267+
evalPackages = hadrianEvalPackages;
265268
modules = [{
266269
reinstallableLibGhc = false;
267270
# Apply the patches in a way that does not require using something
@@ -370,7 +373,7 @@ let
370373
};
371374

372375
in
373-
stdenv.mkDerivation (rec {
376+
haskell-nix.haskellLib.makeCompilerDeps (stdenv.mkDerivation (rec {
374377
version = ghc-version;
375378
name = "${targetPrefix}ghc-${version}" + lib.optionalString (useLLVM) "-llvm";
376379

@@ -658,7 +661,7 @@ stdenv.mkDerivation (rec {
658661
'';
659662

660663
passthru = {
661-
inherit bootPkgs targetPrefix libDir llvmPackages enableShared useLLVM;
664+
inherit bootPkgs targetPrefix libDir llvmPackages enableShared useLLVM hadrian;
662665

663666
# Our Cabal compiler name
664667
haskellCompilerName = "ghc-${version}";
@@ -896,5 +899,5 @@ stdenv.mkDerivation (rec {
896899
cd ../../..
897900
runHook postInstall
898901
'';
899-
});
902+
}));
900903
in self

lib/make-compiler-deps.nix

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{ lib, runCommand }:
2-
let
3-
makeCompilerDeps = ghc: ghc // {
2+
ghc: ghc // {
43
cachedDeps = runCommand "${ghc.name}-deps" {}
54
# First checks that ghc-pkg runs first with `--version` as failures in the `for` and
65
# `if` statements will be masked.
@@ -34,9 +33,4 @@ let
3433
fi
3534
done
3635
'';
37-
} // lib.optionalAttrs (ghc ? dwarf) {
38-
dwarf = makeCompilerDeps ghc.dwarf;
39-
} // lib.optionalAttrs (ghc ? smallAddressSpace) {
40-
smallAddressSpace = makeCompilerDeps ghc.smallAddressSpace;
41-
};
42-
in makeCompilerDeps
36+
}

overlays/cache-compiler-deps.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
final: prev: {
2-
haskell-nix = prev.haskell-nix // {
3-
compiler = __mapAttrs (_: ghc: final.haskell-nix.haskellLib.makeCompilerDeps ghc) prev.haskell-nix.compiler;
4-
};
52
haskell = prev.haskell // {
63
compiler = __mapAttrs (name: ghc: final.haskell-nix.haskellLib.makeCompilerDeps ghc // {
74
inherit (final.haskell-nix.compiler.${name}) raw-src configured-src;

0 commit comments

Comments
 (0)