From feecbd4ee3003e912fd543c863a57b039781cc37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andres=20L=C3=B6h?= <mail@andres-loeh.de>
Date: Mon, 15 Nov 2010 20:28:42 +0000
Subject: [PATCH] Trying to fix priorities of various GHC/Haskell package
 versions.

svn path=/nixpkgs/trunk/; revision=24701
---
 pkgs/top-level/all-packages.nix     | 22 +++++++++++-----------
 pkgs/top-level/haskell-packages.nix | 14 +++++++++-----
 2 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index de34e1076e3b..c674fddc5000 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1820,8 +1820,8 @@ let
   # reducing the number or "enabled" versions again.
 
   # Helper functions to abstract away from repetitive instantiations.
-  haskellPackagesFun = ghcPath : profDefault : recurseIntoAttrs (import ./haskell-packages.nix {
-    inherit pkgs newScope;
+  haskellPackagesFun = ghcPath : profDefault : modifyPrio : recurseIntoAttrs (import ./haskell-packages.nix {
+    inherit pkgs newScope modifyPrio;
     enableLibraryProfiling = getConfig [ "cabal" "libraryProfiling" ] profDefault;
     ghc = callPackage ghcPath {
       ghc = ghc6101Binary;    };
@@ -1829,32 +1829,32 @@ let
 
   # Currently active GHC versions.
   haskellPackages_ghc6101 =
-    haskellPackagesFun ../development/compilers/ghc/6.10.1.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.10.1.nix false (x : x);
 
   haskellPackages_ghc6102 =
-    haskellPackagesFun ../development/compilers/ghc/6.10.2.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.10.2.nix false (x : x);
 
   haskellPackages_ghc6103 =
-    haskellPackagesFun ../development/compilers/ghc/6.10.3.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.10.3.nix false (x : x);
 
   haskellPackages_ghc6104 =
-    haskellPackagesFun ../development/compilers/ghc/6.10.4.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.10.4.nix false (x : x);
 
   haskellPackages_ghc6121 =
-    haskellPackagesFun ../development/compilers/ghc/6.12.1.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.12.1.nix false (x : x);
 
   haskellPackages_ghc6122 =
-    haskellPackagesFun ../development/compilers/ghc/6.12.2.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.12.2.nix false (x : x);
 
   # Current default version.
   haskellPackages_ghc6123 =
-    haskellPackagesFun ../development/compilers/ghc/6.12.3.nix false;
+    haskellPackagesFun ../development/compilers/ghc/6.12.3.nix false (x : x);
 
   haskellPackages_ghc701 =
-    lowPrio (haskellPackagesFun ../development/compilers/ghc/7.0.1.nix false);
+    haskellPackagesFun ../development/compilers/ghc/7.0.1.nix  false lowPrio;
 
   haskellPackages_ghcHEAD =
-    lowPrio (haskellPackagesFun ../development/compilers/ghc/head.nix false);
+    haskellPackagesFun ../development/compilers/ghc/head.nix   false lowPrio;
 
   haxeDist = import ../development/compilers/haxe {
     inherit fetchurl sourceFromHead stdenv lib ocaml zlib makeWrapper neko;
diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix
index 32f4282b9fdd..48cba3d92b85 100644
--- a/pkgs/top-level/haskell-packages.nix
+++ b/pkgs/top-level/haskell-packages.nix
@@ -1,8 +1,12 @@
-{pkgs, newScope, ghc, enableLibraryProfiling ? false}:
+{pkgs, newScope, ghc, enableLibraryProfiling ? false, modifyPrio ? (x : x)}:
 
-let ghcReal = pkgs.lowPrio ghc; in
+let ghcOuter = ghc; in
 
-let result = let callPackage = newScope result; in
+# We redefine callPackage to take into account the new scope. The optional
+# modifyPrio argument can be set to lowPrio to make all Haskell packages have
+# low priority.
+
+let result = let callPackage = x : y : modifyPrio (newScope result x y); in
 
 # Indentation deliberately broken at this point to keep the bulk
 # of this file at a low indentation level.
@@ -13,14 +17,14 @@ rec {
   # -> http://github.com/MarcWeber/hack-nix. Read its README file.
   # You can install (almost) all packages from hackage easily.
 
-  inherit ghcReal;
+  ghcReal = pkgs.lowPrio ghcOuter;
 
   # In the remainder, `ghc' refers to the wrapper.  This is because
   # it's never useful to use the wrapped GHC (`ghcReal'), as the
   # wrapper provides essential functionality: the ability to find
   # Haskell packages in the buildInputs automatically.
   ghc = callPackage ../development/compilers/ghc/wrapper.nix {
-    ghc = ghcReal;
+    ghc = ghcOuter;
   };
 
   cabal = callPackage ../development/libraries/haskell/cabal/cabal.nix {};