Skip to content

Commit 852c521

Browse files
authored
ghc.exactDeps/envDeps built with unpatched ghc (#369)
The `overlays/ghc.nix` overrides were not applied to the `ghc` used to by the `exactDeps` and `envDeps` `passthru` derivations. This resulted in each ghc building twice with only one of them being cached by hydra. This change fixes this by moving the exactDeps and envDeps for ghc into sub directories of the output of the ghc derivation itself.
1 parent 7874deb commit 852c521

File tree

3 files changed

+36
-42
lines changed

3 files changed

+36
-42
lines changed

builder/make-config-files.nix

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let
1212

1313
# Every library component built with `comp-builder.nix` includes an `exactDep`
1414
# and `envDep` directory with precomputed values used here.
15-
# GHC derivations include `exactDep` and `envDep` derivations that have
15+
# GHC derivations include `exactDep` and `envDep` directories that have
1616
# the same information for each of the built in packages.
1717

1818
# exactDep will pass --exact-configuration to the `SETUP_HS confiugre` command.
@@ -38,9 +38,9 @@ let
3838
'';
3939

4040
catGhcPkgExactDep = p: ''
41-
if [ -e ${ghc.exactDeps}/${p} ]; then
42-
cat ${ghc.exactDeps}/${p}/configure-flags >> $out/configure-flags
43-
cat ${ghc.exactDeps}/${p}/cabal.config >> $out/cabal.config
41+
if [ -e ${ghc}/exactDeps/${p} ]; then
42+
cat ${ghc}/exactDeps/${p}/configure-flags >> $out/configure-flags
43+
cat ${ghc}/exactDeps/${p}/cabal.config >> $out/cabal.config
4444
fi
4545
'';
4646

@@ -49,8 +49,8 @@ let
4949
'';
5050

5151
catGhcPkgEnvDep = p: ''
52-
if [ -e ${ghc.envDeps}/${p} ]; then
53-
cat ${ghc.envDeps}/${p} >> $out/ghc-environment
52+
if [ -e ${ghc}/envDeps/${p} ]; then
53+
cat ${ghc}/envDeps/${p} >> $out/ghc-environment
5454
fi
5555
'';
5656

compiler/ghc/default.nix

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
, libiconv ? null, ncurses
1515

16-
, exactDeps, envDeps
16+
, installDeps
1717

1818
, # GHC can be built with system libffi or a bundled one.
1919
libffi ? null
@@ -300,7 +300,7 @@ in let configured-src = stdenv.mkDerivation (rec {
300300
egrep --quiet '^#!' <(head -n 1 $i) || continue
301301
sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
302302
done
303-
'';
303+
'' + installDeps targetPrefix;
304304

305305
passthru = {
306306
inherit bootPkgs targetPrefix;
@@ -315,10 +315,6 @@ in let configured-src = stdenv.mkDerivation (rec {
315315

316316
# Used to detect non haskell-nix compilers (accedental use of nixpkgs compilers can lead to unexpected errors)
317317
isHaskellNixCompiler = true;
318-
319-
# These are used in make-config-files.nix
320-
exactDeps = exactDeps drv;
321-
envDeps = envDeps drv;
322318
} // extra-passthru;
323319

324320
meta = {

overlays/bootstrap.nix

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
self: super:
22
let
3-
exactDeps = ghc: self.runCommand "ghc-exactdep-${ghc.version}" { nativeBuildInputs = [ ghc ]; } ''
4-
for P in $(${ghc.targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9][0-9.]*//g'); do
5-
mkdir -p $out/$P
6-
touch $out/$P/configure-flags
7-
touch $out/$P/cabal.config
8-
9-
if id=$(${ghc.targetPrefix}ghc-pkg field $P id --simple-output); then
10-
echo "--dependency=$P=$id" >> $out/$P/configure-flags
11-
elif id=$(${ghc.targetPrefix}ghc-pkg field "z-$P-z-*" id --simple-output); then
12-
name=$(${ghc.targetPrefix}ghc-pkg field "z-$P-z-*" name --simple-output)
3+
installDeps = targetPrefix: ''
4+
for P in $($out/bin/${targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9][0-9.]*//g'); do
5+
mkdir -p $out/exactDeps/$P
6+
touch $out/exactDeps/$P/configure-flags
7+
touch $out/exactDeps/$P/cabal.config
8+
9+
if id=$($out/bin/${targetPrefix}ghc-pkg field $P id --simple-output); then
10+
echo "--dependency=$P=$id" >> $out/exactDeps/$P/configure-flags
11+
elif id=$($out/bin/${targetPrefix}ghc-pkg field "z-$P-z-*" id --simple-output); then
12+
name=$($out/bin/${targetPrefix}ghc-pkg field "z-$P-z-*" name --simple-output)
1313
# so we are dealing with a sublib. As we build sublibs separately, the above
1414
# query should be safe.
15-
echo "--dependency=''${name#z-$P-z-}=$id" >> $out/$P/configure-flags
15+
echo "--dependency=''${name#z-$P-z-}=$id" >> $out/exactDeps/$P/configure-flags
1616
fi
17-
if ver=$(${ghc.targetPrefix}ghc-pkg field $P version --simple-output); then
18-
echo "constraint: $P == $ver" >> $out/$P/cabal.config
19-
echo "constraint: $P installed" >> $out/$P/cabal.config
17+
if ver=$($out/bin/${targetPrefix}ghc-pkg field $P version --simple-output); then
18+
echo "constraint: $P == $ver" >> $out/exactDeps/$P/cabal.config
19+
echo "constraint: $P installed" >> $out/exactDeps/$P/cabal.config
2020
fi
2121
done
22-
'';
2322
24-
envDeps = ghc: self.runCommand "ghc-envdep-${ghc.version}" { nativeBuildInputs = [ ghc ]; } ''
25-
mkdir -p $out
26-
for P in $(${ghc.targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9.]*//g'); do
27-
touch $out/$P
28-
if id=$(${ghc.targetPrefix}ghc-pkg field $P id --simple-output); then
29-
echo "package-id $id" >> $out/$P
23+
mkdir -p $out/evalDeps
24+
for P in $($out/bin/${targetPrefix}ghc-pkg list --simple-output | sed 's/-[0-9.]*//g'); do
25+
touch $out/evalDeps/$P
26+
if id=$($out/bin/${targetPrefix}ghc-pkg field $P id --simple-output); then
27+
echo "package-id $id" >> $out/evalDeps/$P
3028
fi
3129
done
3230
'';
@@ -105,7 +103,7 @@ in {
105103
ghc844 = self.callPackage ../compiler/ghc {
106104
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc844; };
107105

108-
inherit bootPkgs sphinx exactDeps envDeps;
106+
inherit bootPkgs sphinx installDeps;
109107

110108
buildLlvmPackages = self.buildPackages.llvmPackages_5;
111109
llvmPackages = self.llvmPackages_5;
@@ -123,7 +121,7 @@ in {
123121
ghc861 = self.callPackage ../compiler/ghc {
124122
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc861; };
125123

126-
inherit bootPkgs sphinx exactDeps envDeps;
124+
inherit bootPkgs sphinx installDeps;
127125

128126
buildLlvmPackages = self.buildPackages.llvmPackages_5;
129127
llvmPackages = self.llvmPackages_5;
@@ -139,7 +137,7 @@ in {
139137
ghc862 = self.callPackage ../compiler/ghc {
140138
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc862; };
141139

142-
inherit bootPkgs sphinx exactDeps envDeps;
140+
inherit bootPkgs sphinx installDeps;
143141

144142
buildLlvmPackages = self.buildPackages.llvmPackages_5;
145143
llvmPackages = self.llvmPackages_5;
@@ -156,7 +154,7 @@ in {
156154
ghc863 = self.callPackage ../compiler/ghc {
157155
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc863; };
158156

159-
inherit bootPkgs sphinx exactDeps envDeps;
157+
inherit bootPkgs sphinx installDeps;
160158

161159
buildLlvmPackages = self.buildPackages.llvmPackages_5;
162160
llvmPackages = self.llvmPackages_5;
@@ -173,7 +171,7 @@ in {
173171
ghc864 = self.callPackage ../compiler/ghc {
174172
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc864; };
175173

176-
inherit bootPkgs sphinx exactDeps envDeps;
174+
inherit bootPkgs sphinx installDeps;
177175

178176
buildLlvmPackages = self.buildPackages.llvmPackages_5;
179177
llvmPackages = self.llvmPackages_5;
@@ -190,7 +188,7 @@ in {
190188
ghc865 = self.callPackage ../compiler/ghc {
191189
extra-passthru = { buildGHC = self.buildPackages.haskell-nix.compiler.ghc865; };
192190

193-
inherit bootPkgs sphinx exactDeps envDeps;
191+
inherit bootPkgs sphinx installDeps;
194192

195193
buildLlvmPackages = self.buildPackages.llvmPackages_5;
196194
llvmPackages = self.llvmPackages_5;
@@ -264,10 +262,10 @@ in {
264262
# We mark these compilers as boot compilers to make sure they are only used
265263
# where a boot compiler is expected.
266264
compiler = builtins.mapAttrs (_: v:
267-
v // {
265+
v.overrideAttrs (drv: {
266+
postInstall = (drv.postInstall or "") + installDeps "";
267+
}) // {
268268
isHaskellNixBootCompiler = true;
269-
exactDeps = exactDeps v;
270-
envDeps = envDeps v;
271269
}
272270
)
273271
(import ../compiler/old-ghc-nix { pkgs = self; });

0 commit comments

Comments
 (0)