on iko/ghcjs-patch-master help sign in
Be more liberal about where the index-state comes from (#872)

Fixes #844.

commit0e12a743d6e1698b8ad998bcf0ad0b2d00889f07 authorMichael Peyton Jones <michael.peyton-jones@iohk.io> dateTue 13 Oct 2020, 03:41 (6 years ago) parentddbb4a5
1 file changed+15−12
lib/call-cabal-project-to-nix.nix+15−12
lib/call-cabal-project-to-nix.nix+15−12
@@ -101,17 +101,20 @@ let
101101 )
102102 else null;
103103
104− index-state-found = if index-state != null
104+ cabalProjectIndexState =
105+ if rawCabalProject != null
106+ then pkgs.haskell-nix.haskellLib.parseIndexState rawCabalProject
107+ else null;
108+
109+ index-state-found =
110+ if index-state != null
105111 then index-state
106− else
107− let cabalProjectIndexState = if rawCabalProject != null
108− then pkgs.haskell-nix.haskellLib.parseIndexState rawCabalProject
109− else null;
110− in
111− if cabalProjectIndexState != null
112− then cabalProjectIndexState
113− else builtins.trace ("Using latest index state" + (if name == null then "" else " for " + name) + "!")
114− (pkgs.lib.last (builtins.attrNames index-state-hashes));
112+ else if cabalProjectIndexState != null
113+ then cabalProjectIndexState
114+ else builtins.trace ("Using latest index state" + (if name == null then "" else " for " + name) + "!")
115+ (pkgs.lib.last (builtins.attrNames index-state-hashes));
116+
117+ index-state-pinned = index-state != null || cabalProjectIndexState != null;
115118
116119in
117120 assert (if index-state-found == null
@@ -323,8 +326,8 @@ let
323326 sha256Arg = "plan-sha256";
324327 # Before pinning stuff down we need an index state to use
325328 reasonNotSafe =
326− if index-state == null
327− then "index-state is not set"
329+ if !index-state-pinned
330+ then "index-state is not pinned by an argument or the cabal project file"
328331 else null;
329332 } // pkgs.lib.optionalAttrs (checkMaterialization != null) {
330333 inherit checkMaterialization;