Skip to content

Commit 92b2799

Browse files
authored
Use haskell.nix in for hadrian (#2040)
Using musl64 version of nix-tools goes some way to avoid recompiles of GHC when updating haskell.nix. However any changes that impact the way `hadrian` will be built (for instance changes to `builder/comp-builder.nix`) will cause `hadrian` to need to be rebuilt. This intern causes GHC >=9.4 to need rebuilding. To make this less likely this change adds a `pinned-haskell-nix` using the `nix-tools` subflake. Then hadrian is built using this. Also when the static version of `nix-tools` cannot be used (macOS), a pinned version is used instead. The `nixpkgs` used is also pinned, making it easier for people to use other versions of nixpkgs. The `hackage.nix` is passed in to the `nix-tools` subflake to avoid downloading two copies when setting up a new machine (stackage.nix is not used).
1 parent 77f7f58 commit 92b2799

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

compiler/ghc/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ let
239239
# value for us.
240240
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || stdenv.targetPlatform.isMusl);
241241

242-
hadrian = buildPackages.haskell-nix.tool "ghc8107" "hadrian" {
242+
hadrian = buildPackages.pinned-haskell-nix.tool "ghc8107" "hadrian" {
243243
compilerSelection = p: p.haskell.compiler;
244244
index-state = buildPackages.haskell-nix.internalHackageIndexState;
245245
# Verions of hadrian that comes with 9.6 depends on `time`

flake.nix

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,15 @@
156156
let
157157
legacyPackages = (self.internal.compat { inherit system; }).pkgs;
158158
nix-tools-hydraJobs =
159-
let cf = callFlake { pkgs = legacyPackages; inherit system; src = ./nix-tools; };
159+
let cf = callFlake {
160+
pkgs = legacyPackages;
161+
inherit system;
162+
src = ./nix-tools;
163+
override-inputs = {
164+
# Avoid downloading another `hackage.nix`.
165+
inherit (inputs) hackage;
166+
};
167+
};
160168
in cf.defaultNix.hydraJobs;
161169
in rec {
162170
inherit legacyPackages;

nix-tools/flake.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
systems = [
88
"x86_64-linux"
99
"x86_64-darwin"
10-
# TODO switch back on when ci.iog.io has builders for aarch64-linux
11-
# "aarch64-linux"
10+
"aarch64-linux"
1211
"aarch64-darwin"
1312
];
1413

@@ -48,6 +47,10 @@
4847

4948
legacyPackages = forAllSystems (pkgs: pkgs);
5049

50+
lib = {
51+
nix-tools = system: (haskellNix.legacyPackages.${system}.extend self.overlays.default).nix-tools;
52+
haskell-nix = system: (haskellNix.legacyPackages.${system}.extend self.overlays.default).haskell-nix;
53+
};
5154
project = forAllSystems (pkgs: pkgs.nix-tools.project);
5255

5356
packages = forAllSystems (pkgs:

overlays/default.nix

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,31 @@ let
4343
# add the missing exes attributes to the tarball derivation
4444
tarball // { exes = final.lib.genAttrs nix-tools-provided-exes (_: tarball); };
4545

46-
# Are we going to use the tarball?
47-
use-tarball = final.stdenv.hostPlatform.isLinux && final.stdenv.hostPlatform.isx86_64;
46+
# Version of nix-tools built with a pinned version of haskell.nix.
47+
pinned-nix-tools-lib = (import (final.haskell-nix.sources.flake-compat) {
48+
pkgs = final;
49+
inherit (final) system;
50+
src = ../nix-tools;
51+
override-inputs = {
52+
# Avoid downloading another `hackage.nix`.
53+
inherit (final.haskell-nix.sources) hackage;
54+
};
55+
}).defaultNix.lib;
4856
in
4957
{
5058
haskell-nix =
5159
prev.haskell-nix // {
5260
inherit (nix-tools-pkgs) nix-tools nix-tools-set;
5361
# either nix-tools from its overlay or from the tarball.
54-
nix-tools-unchecked = if use-tarball then static-nix-tools else nix-tools-pkgs.nix-tools;
62+
nix-tools-unchecked =
63+
# If possible use the static nix-tools tarball
64+
if final.stdenv.hostPlatform.isLinux && final.stdenv.hostPlatform.isx86_64
65+
then static-nix-tools
66+
else pinned-nix-tools-lib.nix-tools final.system;
5567
};
68+
# For use building hadrian. This way updating anything that modifies the
69+
# way hadrian is built will not cause a GHC rebuild.
70+
pinned-haskell-nix = pinned-nix-tools-lib.haskell-nix final.system;
5671
});
5772

5873
bootstrap = import ./bootstrap.nix;

0 commit comments

Comments
 (0)