on iko/ghcjs-patch-master help sign in
Externalize error msg functions (#588)

* move error messages functions from hackage.nix to haskell.nix Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>

commitd47ae23df046500f3388cddc38a875f3f5ea4b8f authorJean-Baptiste Giraudeau <jean-baptiste.giraudeau@iohk.io> dateSat 9 May 2020, 05:08 (6 years ago) parent49ecc0e
3 files changed+47−4
modules/component-driver.nix+3−4 modules/error-handler.nix+41 package-set.nix+3
modules/component-driver.nix+3−4
@@ -74,10 +74,9 @@ in
7474 };
7575
7676 config.bootPkgs = [
77− "rts" "ghc-boot-th"
78− "ghc-heap" # since ghc 8.6.
79− ]
80− ++ lib.optional (!config.reinstallableLibGhc) "ghc";
77+ "rts" "ghc-boot-th"
78+ "ghc-heap" # since ghc 8.6.
79+ ] ++ lib.optional (!config.reinstallableLibGhc) "ghc";
8180
8281 options.hsPkgs = lib.mkOption {
8382 type = lib.types.unspecified;
modules/error-handler.nixnew file+41
@@ -0,0 +1,41 @@
1+{ lib, config, ... }:
2+{
3+ options.errorHandler = lib.mkOption {
4+ type = lib.types.unspecified;
5+ };
6+
7+ config.errorHandler = {
8+ buildDepError = pkg:
9+ builtins.throw ''
10+ The Haskell package set does not contain the package: ${pkg} (build dependency).
11+ If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
12+ '';
13+ sysDepError = pkg:
14+ builtins.throw ''
15+ The Nixpkgs package set does not contain the package: ${pkg} (system dependency).
16+ You may need to augment the system package mapping in haskell.nix so that it can be found.
17+ '';
18+ pkgConfDepError = pkg:
19+ builtins.throw ''
20+ The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency).
21+ You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found.
22+ '';
23+ exeDepError = pkg:
24+ builtins.throw ''
25+ The local executable components do not include the component: ${pkg} (executable dependency).
26+ '';
27+ legacyExeDepError = pkg:
28+ builtins.throw ''
29+ The Haskell package set does not contain the package: ${pkg} (executable dependency).
30+ If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
31+ '';
32+ buildToolDepError = pkg:
33+ builtins.throw ''
34+ Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency).
35+ If this is a system dependency:
36+ You may need to augment the system package mapping in haskell.nix so that it can be found.
37+ If this is a Haskell dependency:
38+ If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
39+ '';
40+ };
41+}
package-set.nix+3
@@ -83,6 +83,9 @@ in pkgs.lib.evalModules {
8383
8484 })
8585
86+ # Error handlers
87+ ./modules/error-handler.nix
88+
8689 # Supplies metadata
8790 ./modules/cabal.nix
8891