summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/beam-modules/default.nix7
-rw-r--r--pkgs/development/haskell-modules/default.nix20
-rw-r--r--pkgs/development/haskell-modules/make-package-set.nix34
-rw-r--r--pkgs/development/idris-modules/default.nix11
-rw-r--r--pkgs/top-level/all-packages.nix4
-rw-r--r--pkgs/top-level/haskell-packages.nix41
-rw-r--r--pkgs/top-level/splice.nix4
7 files changed, 82 insertions, 39 deletions
diff --git a/pkgs/development/beam-modules/default.nix b/pkgs/development/beam-modules/default.nix
index 95fe683cd1e5..1d4cef685148 100644
--- a/pkgs/development/beam-modules/default.nix
+++ b/pkgs/development/beam-modules/default.nix
@@ -5,9 +5,14 @@ let
 
   lib = pkgs.callPackage ./lib.nix {};
 
+  # FIXME: add support for overrideScope
+  callPackageWithScope = scope: drv: args: stdenv.lib.callPackageWith scope drv args;
+  mkScope = scope: pkgs // scope;
+
   packages = self:
     let
-      callPackage = stdenv.lib.callPackageWith (pkgs // self);
+      defaultScope = mkScope self;
+      callPackage = drv: args: callPackageWithScope defaultScope drv args;
     in
       import ./hex-packages.nix {
         inherit pkgs stdenv callPackage;
diff --git a/pkgs/development/haskell-modules/default.nix b/pkgs/development/haskell-modules/default.nix
index 9eeae0eddc76..1658ce793936 100644
--- a/pkgs/development/haskell-modules/default.nix
+++ b/pkgs/development/haskell-modules/default.nix
@@ -7,8 +7,6 @@
 , configurationNix ? import ./configuration-nix.nix
 }:
 
-self: # Provided by `callPackageWithOutput`
-
 let
 
   inherit (lib) extends makeExtensible;
@@ -16,15 +14,19 @@ let
 
   haskellPackages = pkgs.callPackage makePackageSet {
     package-set = initialPackages;
-    extensible-self = self;
-    inherit stdenv haskellLib ghc;
+    inherit stdenv haskellLib ghc extensible-self;
   };
 
   commonConfiguration = configurationCommon { inherit pkgs haskellLib; };
   nixConfiguration = configurationNix { inherit pkgs haskellLib; };
 
-in (extends overrides
-     (extends packageSetConfig
-       (extends compilerConfig
-         (extends commonConfiguration
-           (extends nixConfiguration haskellPackages))))) self
+  extensible-self = makeExtensible
+    (extends overrides
+      (extends packageSetConfig
+        (extends compilerConfig
+          (extends commonConfiguration
+            (extends nixConfiguration haskellPackages)))));
+
+in
+
+  extensible-self
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix
index b6bd3fdd30b7..ff5be894b926 100644
--- a/pkgs/development/haskell-modules/make-package-set.nix
+++ b/pkgs/development/haskell-modules/make-package-set.nix
@@ -29,7 +29,7 @@ self:
 
 let
 
-  inherit (stdenv.lib) fix' extends makeOverridable callPackageWith;
+  inherit (stdenv.lib) fix' extends makeOverridable;
   inherit (haskellLib) overrideCabal;
 
   mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
@@ -61,9 +61,39 @@ let
 
   mkDerivation = makeOverridable mkDerivationImpl;
 
+  # manualArgs are the arguments that were explictly passed to `callPackage`, like:
+  #
+  # callPackage foo { bar = null; };
+  #
+  # here `bar` is a manual argument.
+  callPackageWithScope = scope: fn: manualArgs:
+    let
+      # this code is copied from callPackage in lib/customisation.nix
+      #
+      # we cannot use `callPackage` here because we want to call `makeOverridable`
+      # on `drvScope` (we cannot add `overrideScope` after calling `callPackage` because then it is
+      # lost on `.override`) but determine the auto-args based on `drv` (the problem here
+      # is that nix has no way to "passthrough" args while preserving the reflection
+      # info that callPackage uses to determine the arguments).
+      drv = if builtins.isFunction fn then fn else import fn;
+      auto = builtins.intersectAttrs (builtins.functionArgs drv) scope;
+
+      # this wraps the `drv` function to add a `overrideScope` function to the result.
+      drvScope = allArgs: drv allArgs // {
+        overrideScope = f:
+          let newScope = mkScope (fix' (extends f scope.__unfix__));
+          # note that we have to be careful here: `allArgs` includes the auto-arguments that
+          # weren't manually specified. If we would just pass `allArgs` to the recursive call here,
+          # then we wouldn't look up any packages in the scope in the next interation, because it
+          # appears as if all arguments were already manually passed, so the scope change would do
+          # nothing.
+          in callPackageWithScope newScope drv manualArgs;
+      };
+    in stdenv.lib.makeOverridable drvScope (auto // manualArgs);
+
   mkScope = scope: pkgs // pkgs.xorg // pkgs.gnome2 // { inherit stdenv; } // scope;
   defaultScope = mkScope self;
-  callPackage = drv: args: callPackageWith defaultScope drv args;
+  callPackage = drv: args: callPackageWithScope defaultScope drv args;
 
   withPackages = packages: callPackage ./with-packages-wrapper.nix {
     inherit (self) llvmPackages;
diff --git a/pkgs/development/idris-modules/default.nix b/pkgs/development/idris-modules/default.nix
index cb8f46d0c2e7..4d7c4928283a 100644
--- a/pkgs/development/idris-modules/default.nix
+++ b/pkgs/development/idris-modules/default.nix
@@ -1,8 +1,17 @@
 { pkgs, idris, overrides ? (self: super: {}) }: let
   inherit (pkgs.lib) callPackageWith fix' extends;
 
+  /* Taken from haskell-modules/default.nix, should probably abstract this away */
+  callPackageWithScope = scope: drv: args: (callPackageWith scope drv args) // {
+    overrideScope = f: callPackageWithScope (mkScope (fix' (extends f scope.__unfix__))) drv args;
+  };
+
+  mkScope = scope : pkgs // pkgs.xorg // pkgs.gnome2 // scope;
+
   idrisPackages = self: let
-    callPackage = callPackageWith (pkgs // pkgs.xorg // pkgs.gnome2 // self);
+    defaultScope = mkScope self;
+
+    callPackage = callPackageWithScope defaultScope;
 
     builtins_ = pkgs.lib.mapAttrs self.build-builtin-package {
       prelude = [];
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 19452e0d6c0c..7e94b3f0c0a4 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -5710,7 +5710,9 @@ with pkgs;
 
   haskell = callPackage ./haskell-packages.nix { };
 
-  haskellPackages = haskell.packages.ghc802.extend (config.haskellPackageOverrides or (self: super: {}));
+  haskellPackages = haskell.packages.ghc802.override {
+    overrides = config.haskellPackageOverrides or (self: super: {});
+  };
 
   inherit (haskellPackages) ghc;
 
diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix
index a1f9b2e81c3c..b3bbb0d5b643 100644
--- a/pkgs/top-level/haskell-packages.nix
+++ b/pkgs/top-level/haskell-packages.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib, stdenv, buildPlatform, targetPlatform }:
+{ pkgs, lib, newScope, stdenv, buildPlatform, targetPlatform }:
 
 let
   # These are attributes in compiler and packages that don't support integer-simple.
@@ -23,8 +23,7 @@ let
     inherit pkgs;
   };
 
-  callPackage = lib.callPackageWith (pkgs // { inherit haskellLib; });
-  callPackageWithOutput = lib.callPackageWithOutputWith (pkgs // { inherit haskellLib; });
+  callPackage = newScope { inherit haskellLib; };
 
 in rec {
   lib = haskellLib;
@@ -122,75 +121,75 @@ in rec {
   packages = {
 
     # Support for this compiler is broken, because it can't deal with directory-based package databases.
-    # ghc6104 = callPackageWithOutput ../development/haskell-modules { ghc = compiler.ghc6104; };
-    ghc6123 = callPackageWithOutput ../development/haskell-modules {
+    # ghc6104 = callPackage ../development/haskell-modules { ghc = compiler.ghc6104; };
+    ghc6123 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc6123;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-6.12.x.nix { };
     };
-    ghc704 = callPackageWithOutput ../development/haskell-modules {
+    ghc704 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc704;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.0.x.nix { };
     };
-    ghc722 = callPackageWithOutput ../development/haskell-modules {
+    ghc722 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc722;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.2.x.nix { };
     };
-    ghc742 = callPackageWithOutput ../development/haskell-modules {
+    ghc742 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc742;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.4.x.nix { };
     };
-    ghc763 = callPackageWithOutput ../development/haskell-modules {
+    ghc763 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc763;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.6.x.nix { };
     };
-    ghc783 = callPackageWithOutput ../development/haskell-modules {
+    ghc783 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc783;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.8.x.nix { };
     };
-    ghc784 = callPackageWithOutput ../development/haskell-modules {
+    ghc784 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc784;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.8.x.nix { };
     };
-    ghc7102 = callPackageWithOutput ../development/haskell-modules {
+    ghc7102 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc7102;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.10.x.nix { };
     };
-    ghc7103 = callPackageWithOutput ../development/haskell-modules {
+    ghc7103 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc7103;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.10.x.nix { };
     };
-    ghc802 = callPackageWithOutput ../development/haskell-modules {
+    ghc802 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc802;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.0.x.nix { };
     };
-    ghc821 = callPackageWithOutput ../development/haskell-modules {
+    ghc821 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc821;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.2.x.nix { };
     };
-    ghcHEAD = callPackageWithOutput ../development/haskell-modules {
+    ghcHEAD = callPackage ../development/haskell-modules {
       ghc = compiler.ghcHEAD;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { };
     };
     # TODO Support for multiple variants here
-    ghcCross = callPackageWithOutput ../development/haskell-modules {
+    ghcCross = callPackage ../development/haskell-modules {
       ghc = compiler.ghcHEAD.crossCompiler;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { };
     };
-    ghcCross821 = callPackageWithOutput ../development/haskell-modules {
+    ghcCross821 = callPackage ../development/haskell-modules {
       ghc = compiler.ghc821.crossCompiler;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.2.x.nix { };
     };
-    ghcjs = callPackageWithOutput ../development/haskell-modules {
+    ghcjs = callPackage ../development/haskell-modules {
       ghc = compiler.ghcjs;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.10.x.nix { };
       packageSetConfig = callPackage ../development/haskell-modules/configuration-ghcjs.nix { };
     };
-    ghcjsHEAD = callPackageWithOutput ../development/haskell-modules {
+    ghcjsHEAD = callPackage ../development/haskell-modules {
       ghc = compiler.ghcjsHEAD;
       compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.0.x.nix { };
       packageSetConfig = callPackage ../development/haskell-modules/configuration-ghcjs.nix { };
     };
-    ghcHaLVM240 = callPackageWithOutput ../development/haskell-modules {
+    ghcHaLVM240 = callPackage ../development/haskell-modules {
       ghc = compiler.ghcHaLVM240;
       compilerConfig = callPackage ../development/haskell-modules/configuration-halvm-2.4.0.nix { };
     };
diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix
index d6498be949b3..44a46b7b6929 100644
--- a/pkgs/top-level/splice.nix
+++ b/pkgs/top-level/splice.nix
@@ -80,11 +80,7 @@ in
   # `newScope' for sets of packages in `pkgs' (see e.g. `gnome' below).
   callPackage = pkgs.newScope {};
 
-  callPackageWithOutput = pkgs.newScopeWithOutput {};
-
   callPackages = lib.callPackagesWith splicedPackages;
 
   newScope = extra: lib.callPackageWith (splicedPackages // extra);
-
-  newScopeWithOutput = extra: lib.callPackageWithOutputWith (splicedPackages // extra);
 }