summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2018-04-23 21:07:58 +0200
committerGitHub <noreply@github.com>2018-04-23 21:07:58 +0200
commit21d688f9b82e00ec29847578be6176e81131cd3c (patch)
tree6925eae4480d6399d56ed9349a6bc52b358542d5
parent42a9ba28d116420424e935668890d4d1e810d982 (diff)
parentbf6d796a2763f2f58c8e04f9505478d478de0e97 (diff)
downloadnixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.tar
nixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.tar.gz
nixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.tar.bz2
nixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.tar.lz
nixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.tar.xz
nixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.tar.zst
nixpkgs-21d688f9b82e00ec29847578be6176e81131cd3c.zip
Merge pull request #39309 from LumiGuide/haskell.overrides
RFC: haskell: allow overriding all package sets at once
-rw-r--r--doc/languages-frameworks/haskell.section.md50
-rw-r--r--pkgs/top-level/haskell-packages.nix8
2 files changed, 57 insertions, 1 deletions
diff --git a/doc/languages-frameworks/haskell.section.md b/doc/languages-frameworks/haskell.section.md
index 1623e0d276f..3b8971c295b 100644
--- a/doc/languages-frameworks/haskell.section.md
+++ b/doc/languages-frameworks/haskell.section.md
@@ -666,6 +666,56 @@ prefer one built with GHC 7.8.x in the first place. However, for users who
 cannot use GHC 7.10.x at all for some reason, the approach of downgrading to an
 older version might be useful.
 
+### How to override packages in all compiler-specific package sets
+
+In the previous section we learned how to override a package in a single
+compiler-specific package set. You may have some overrides defined that you want
+to use across multiple package sets. To accomplish this you could use the
+technique that we learned in the previous section by repeating the overrides for
+all the compiler-specific package sets. For example:
+
+```nix
+{
+  packageOverrides = super: let self = super.pkgs; in
+  {
+    haskell = super.haskell // {
+      packages = super.haskell.packages // {
+        ghc784 = super.haskell.packages.ghc784.override {
+          overrides = self: super: {
+            my-package = ...;
+            my-other-package = ...;
+          };
+        };
+        ghc822 = super.haskell.packages.ghc784.override {
+          overrides = self: super: {
+            my-package = ...;
+            my-other-package = ...;
+          };
+        };
+        ...
+      };
+    };
+  };
+}
+```
+
+However there's a more convenient way to override all compiler-specific package
+sets at once:
+
+```nix
+{
+  packageOverrides = super: let self = super.pkgs; in
+  {
+    haskell = super.haskell // {
+      packageOverrides = self: super: {
+        my-package = ...;
+        my-other-package = ...;
+      };
+    };
+  };
+}
+```
+
 ### How to recover from GHC's infamous non-deterministic library ID bug
 
 GHC and distributed build farms don't get along well:
diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix
index f9cd2eb9433..48980e48f1d 100644
--- a/pkgs/top-level/haskell-packages.nix
+++ b/pkgs/top-level/haskell-packages.nix
@@ -19,7 +19,10 @@ let
     inherit pkgs;
   };
 
-  callPackage = newScope { inherit haskellLib; };
+  callPackage = newScope {
+    inherit haskellLib;
+    overrides = pkgs.haskell.packageOverrides;
+  };
 
   bootstrapPackageSet = self: super: {
     mkDerivation = drv: super.mkDerivation (drv // {
@@ -99,6 +102,9 @@ in rec {
       (name: compiler."${name}".override { enableIntegerSimple = true; }));
   };
 
+  # Default overrides that are applied to all package sets.
+  packageOverrides = self : super : {};
+
   # Always get compilers from `buildPackages`
   packages = let bh = buildPackages.haskell; in {