From 0ffde453f3734522cf4e1f33db749f41795070c7 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 12 Aug 2020 23:07:04 +1200 Subject: [PATCH] Allow older `ghc` versions in `cabalProject` Currently the `dummy-ghc-data`, `nix-tools` plan and `cabal-install` plan must be materialized for the selected `ghc`. This change relaxes that restriction and will instead use `nix-tools` and `cabal-install` built with a fixed `ghc` version (currently `ghc865`) and will calculate the `dummy-ghc-data` as an IFD. It will `__trace` a warning of the form: ``` WARNING: No materialized dummy-ghc-data for ghc-8.6.4-x86_64-darwin. ``` --- lib/call-cabal-project-to-nix.nix | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 7d99a03e8e..e696b1e789 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -21,8 +21,8 @@ in , caller ? "callCabalProjectToNix" # Name of the calling funcion for better warning messages , ghc ? null # Deprecated in favour of `compiler-nix-name` , ghcOverride ? null # Used when we need to set ghc explicitly during bootstrapping -, nix-tools ? evalPackages.haskell-nix.nix-tools.${compiler-nix-name} # When building cabal projects we use the nix-tools -, cabal-install ? evalPackages.haskell-nix.cabal-install.${compiler-nix-name} # and cabal-install compiled with matching ghc version +, nix-tools ? evalPackages.haskell-nix.nix-tools-unchecked.${compiler-nix-name} # When building cabal projects we use the nix-tools +, cabal-install ? evalPackages.haskell-nix.cabal-install-unchecked.${compiler-nix-name} # and cabal-install compiled with matching ghc version , configureArgs ? "" # Extra arguments to pass to `cabal v2-configure`. # `--enable-tests --enable-benchmarks` are included by default. # If the tests and benchmarks are not needed and they @@ -212,14 +212,21 @@ let # The solution here is to capture the GHC outputs that `cabal v2-configure` # requests and materialize it so that the real GHC is only needed # when `checkMaterialization` is set. - dummy-ghc-data = pkgs.haskell-nix.materialize ({ - sha256 = null; - sha256Arg = "sha256"; - materialized = ../materialized/dummy-ghc + "/${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}"; - reasonNotSafe = null; - } // pkgs.lib.optionalAttrs (checkMaterialization != null) { - inherit checkMaterialization; - }) ( + dummy-ghc-data = + let + materialized = ../materialized/dummy-ghc + "/${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}"; + in pkgs.haskell-nix.materialize ({ + sha256 = null; + sha256Arg = "sha256"; + materialized = if __pathExists materialized + then materialized + else __trace ("WARNING: No materialized dummy-ghc-data for " + + "${ghc.targetPrefix}${ghc.name}-${pkgs.stdenv.buildPlatform.system}.") + null; + reasonNotSafe = null; + } // pkgs.lib.optionalAttrs (checkMaterialization != null) { + inherit checkMaterialization; + }) ( runCommand ("dummy-data-" + ghc.name) { nativeBuildInputs = [ ghc ]; } ''