about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-09-28 18:10:50 -0400
committerShea Levy <shea@shealevy.com>2017-09-28 18:10:50 -0400
commitc3af1210b4c5d7ef380e75add463b37574fdcc8b (patch)
tree0e97578072574d3c971c5c225289f13118e80a50 /pkgs/development
parent49f175cd0c80a39e1d05fc687c4a2a40e0aba58c (diff)
parentdbd500937644c2deae4a2c7a59f4a11a006bf1d0 (diff)
downloadnixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.tar
nixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.tar.gz
nixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.tar.bz2
nixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.tar.lz
nixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.tar.xz
nixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.tar.zst
nixlib-c3af1210b4c5d7ef380e75add463b37574fdcc8b.zip
Merge branch 'improved-make-overridable' of git://github.com/ElvishJerricco/nixpkgs
Diffstat (limited to 'pkgs/development')
-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
4 files changed, 13 insertions, 59 deletions
diff --git a/pkgs/development/beam-modules/default.nix b/pkgs/development/beam-modules/default.nix
index 1d4cef685148..95fe683cd1e5 100644
--- a/pkgs/development/beam-modules/default.nix
+++ b/pkgs/development/beam-modules/default.nix
@@ -5,14 +5,9 @@ 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
-      defaultScope = mkScope self;
-      callPackage = drv: args: callPackageWithScope defaultScope drv args;
+      callPackage = stdenv.lib.callPackageWith (pkgs // self);
     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 1658ce793936..9eeae0eddc76 100644
--- a/pkgs/development/haskell-modules/default.nix
+++ b/pkgs/development/haskell-modules/default.nix
@@ -7,6 +7,8 @@
 , configurationNix ? import ./configuration-nix.nix
 }:
 
+self: # Provided by `callPackageWithOutput`
+
 let
 
   inherit (lib) extends makeExtensible;
@@ -14,19 +16,15 @@ let
 
   haskellPackages = pkgs.callPackage makePackageSet {
     package-set = initialPackages;
-    inherit stdenv haskellLib ghc extensible-self;
+    extensible-self = self;
+    inherit stdenv haskellLib ghc;
   };
 
   commonConfiguration = configurationCommon { inherit pkgs haskellLib; };
   nixConfiguration = configurationNix { inherit pkgs haskellLib; };
 
-  extensible-self = makeExtensible
-    (extends overrides
-      (extends packageSetConfig
-        (extends compilerConfig
-          (extends commonConfiguration
-            (extends nixConfiguration haskellPackages)))));
-
-in
-
-  extensible-self
+in (extends overrides
+     (extends packageSetConfig
+       (extends compilerConfig
+         (extends commonConfiguration
+           (extends nixConfiguration haskellPackages))))) self
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix
index ff5be894b926..b6bd3fdd30b7 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;
+  inherit (stdenv.lib) fix' extends makeOverridable callPackageWith;
   inherit (haskellLib) overrideCabal;
 
   mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
@@ -61,39 +61,9 @@ 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: callPackageWithScope defaultScope drv args;
+  callPackage = drv: args: callPackageWith 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 4d7c4928283a..cb8f46d0c2e7 100644
--- a/pkgs/development/idris-modules/default.nix
+++ b/pkgs/development/idris-modules/default.nix
@@ -1,17 +1,8 @@
 { 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
-    defaultScope = mkScope self;
-
-    callPackage = callPackageWithScope defaultScope;
+    callPackage = callPackageWith (pkgs // pkgs.xorg // pkgs.gnome2 // self);
 
     builtins_ = pkgs.lib.mapAttrs self.build-builtin-package {
       prelude = [];