on iko/ghcjs-patch-master help sign in
Pin the index-state used by ghc dependencies (#264)

* Pin the index-state used by ghc dependencies Currently when a new hackage index-state is available (every day on haskell.nix/master branch) the index-state used alex, happy and hscolour is in the bootPkgs is updates to that latest one. This results in a rebuild of GHC (even though the build plans are likely unchanged). By pinning the index state for these bootPkgs nix will be able to reuse GHC. The only down side is that if we need to get new versions of alex, happy and hscolour into bootPkgs we will likely need to bump the index-state attributes as well as the version.

commit3984c0e2a6c2a28f6803d080fb81ca40ca7ccb9d authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateTue 22 Oct 2019, 22:14 (7 years ago) parentd6255c9
4 files changed+21−12
lib/call-cabal-project-to-nix.nix+14−5 overlays/bootstrap.nix+3 overlays/ghc-packages.nix+1 overlays/haskell.nix+3−7
lib/call-cabal-project-to-nix.nix+14−5
@@ -1,5 +1,6 @@
11{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib }@defaults:
2−{ src
2+{ name ? null # optional name for better error messages
3+, src
34, index-state ? null
45, index-sha256 ? null
56, cabalProject ? null
@@ -47,9 +48,15 @@ let
4748
4849 index-state-found = if index-state != null
4950 then index-state
50− else if rawCabalProject != null
51− then parseIndexState rawCabalProject
52− else null;
51+ else
52+ let cabalProjectIndexState = if rawCabalProject != null
53+ then parseIndexState rawCabalProject
54+ else null;
55+ in
56+ if cabalProjectIndexState != null
57+ then cabalProjectIndexState
58+ else builtins.trace ("Using latest index state" + (if name == null then "" else " for " + name) + "!")
59+ (pkgs.lib.last (builtins.attrNames index-state-hashes));
5360
5461 # Lookup hash for the index state we found
5562 index-sha256-found = if index-sha256 != null
@@ -161,7 +168,9 @@ let
161168 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
162169 HOME=${dotCabal {
163170 inherit cabal-install nix-tools;
164− index-state = index-state-found;
171+ index-state =
172+ builtins.trace ("Using index-state: ${index-state-found}" + (if name == null then "" else " for " + name))
173+ index-state-found;
165174 sha256 = index-sha256-found; }} cabal new-configure \
166175 --with-ghc=${ghc.targetPrefix}ghc \
167176 --with-ghc-pkg=${ghc.targetPrefix}ghc-pkg \
overlays/bootstrap.nix+3
@@ -269,17 +269,20 @@ self: super: rec {
269269 inherit ghc;
270270 inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
271271 name = "alex"; version = "3.2.4";
272+ index-state = "2019-10-20T00:00:00Z";
272273 }).components.exes.alex;
273274 happy = (hackage-package {
274275 inherit ghc;
275276 inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
276277 name = "happy"; version = "1.19.11";
278+ index-state = "2019-10-20T00:00:00Z";
277279 }).components.exes.happy;
278280
279281 hscolour = (hackage-package {
280282 inherit ghc;
281283 inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
282284 name = "hscolour"; version = "1.24.4";
285+ index-state = "2019-10-20T00:00:00Z";
283286 }).components.exes.HsColour;
284287 };
285288 };
overlays/ghc-packages.nix+1
@@ -82,6 +82,7 @@ in rec {
8282 }) self.buildPackages.haskell.compiler;
8383
8484 ghc-extra-packages = builtins.mapAttrs (name: proj: self.haskell-nix.cabalProject {
85+ name = "ghc-extra-packages";
8586 src = proj;
8687 ghc = self.buildPackages.haskell.compiler.${name};
8788 })
overlays/haskell.nix+3−7
@@ -260,7 +260,6 @@ self: super: {
260260 hackage-project =
261261 { name
262262 , version
263− , index-state ? builtins.trace "Using latest index state!" self.lib.last (builtins.attrNames (import indexStateHashesPath))
264263 , ... }@args:
265264 let tarball = self.pkgs.fetchurl {
266265 url = "mirror://hackage/${name}-${version}.tar.gz";
@@ -271,15 +270,12 @@ self: super: {
271270 tar xzf ${tarball}
272271 mv "${name}-${version}" $out
273272 '';
274− in cabalProject (builtins.removeAttrs args [ "name" "version" ] // { inherit index-state src; });
273+ in cabalProject (builtins.removeAttrs args [ "version" ] // { inherit src; });
275274
276275 cabalProject' =
277− { index-state ? builtins.trace "Using latest index state!" self.lib.last (builtins.attrNames (import indexStateHashesPath))
276+ { name ? null
278277 , ... }@args:
279− let plan = (importAndFilterProject
280− (callCabalProjectToNix
281− (builtins.trace "Using index-state: ${index-state}"
282− (args // { inherit index-state; }))));
278+ let plan = importAndFilterProject (callCabalProjectToNix args);
283279 in let pkg-set = mkCabalProjectPkgSet
284280 { plan-pkgs = plan.pkgs;
285281 pkg-def-extras = args.pkg-def-extras or [];