about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2017-08-01 12:44:08 -0400
committerPeter Simons <simons@cryp.to>2017-08-03 13:12:01 +0200
commit74f5fe50681003f075bf0b1ff811d0c0cd7c64f3 (patch)
tree3778107673a5b406aaca29fe5901c0cf998af555 /pkgs/development
parenta2825a3c6f445175d4ad8dc52b8c02af3c629571 (diff)
downloadnixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.tar
nixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.tar.gz
nixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.tar.bz2
nixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.tar.lz
nixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.tar.xz
nixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.tar.zst
nixlib-74f5fe50681003f075bf0b1ff811d0c0cd7c64f3.zip
haskell infra: Misc cleanups
 - The haskell lib is very close to not relying on Nixpkgs. I think
   this is good---simpler to think about and matches Nixpkgs's lib.

 - The haskell lib is only imported once

 - stdenv is exposed more shallowly so it can be overriden more easily.
   I'll eventually use this on Darwin to avoid the Sierra shared
   library problems (unless changes are to be made system-wide).

Closes https://github.com/NixOS/nixpkgs/pull/27840.
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/haskell-modules/configuration-common.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghc-head.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-ghcjs.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix4
-rw-r--r--pkgs/development/haskell-modules/configuration-nix.nix4
-rw-r--r--pkgs/development/haskell-modules/default.nix14
-rw-r--r--pkgs/development/haskell-modules/lib.nix17
-rw-r--r--pkgs/development/haskell-modules/make-package-set.nix30
-rw-r--r--pkgs/development/tools/haskell/lambdabot/default.nix4
18 files changed, 68 insertions, 53 deletions
diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix
index 2d0d0ec101db..634d46597b9c 100644
--- a/pkgs/development/haskell-modules/configuration-common.nix
+++ b/pkgs/development/haskell-modules/configuration-common.nix
@@ -9,9 +9,9 @@
 #
 # See comment at the top of configuration-nix.nix for more information about this
 # distinction.
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix b/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix
index 6be7ae16572a..387754d674e2 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix
index c2a7e0014056..3edbc0d398bf 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix
index 7f561133b64e..4a09b142d2ea 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix
index 911fb8640f42..75e0c9c0bcb2 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix
index 8a6d22bcc7ec..1b15f4f105be 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix
index 43ec45bf8217..a096dc9ce8cd 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix b/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix
index a97cbfde4fc9..f82bcb4e646c 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix b/pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix
index bc72ec031adb..a24d2bcd4c1f 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix b/pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix
index 6f4ced675b3c..d1e22d881c35 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghc-head.nix b/pkgs/development/haskell-modules/configuration-ghc-head.nix
index 6a9d15d402ef..4b7fc3d83603 100644
--- a/pkgs/development/haskell-modules/configuration-ghc-head.nix
+++ b/pkgs/development/haskell-modules/configuration-ghc-head.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-ghcjs.nix b/pkgs/development/haskell-modules/configuration-ghcjs.nix
index 7efb75c33296..0f17f5ce707b 100644
--- a/pkgs/development/haskell-modules/configuration-ghcjs.nix
+++ b/pkgs/development/haskell-modules/configuration-ghcjs.nix
@@ -2,14 +2,14 @@
 #
 # Please insert new packages *alphabetically*
 # in the OTHER PACKAGES section.
-{ pkgs }:
+{ pkgs, haskellLib }:
 
 let
   removeLibraryHaskellDepends = pnames: depends:
     builtins.filter (e: !(builtins.elem (e.pname or "") pnames)) depends;
 in
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super:
 
diff --git a/pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix b/pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix
index cd7857e23de9..be90794f58d9 100644
--- a/pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix
+++ b/pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix
@@ -1,6 +1,6 @@
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 self: super: {
 
diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix
index 7b9dbcdaa792..4dce5d59d4ad 100644
--- a/pkgs/development/haskell-modules/configuration-nix.nix
+++ b/pkgs/development/haskell-modules/configuration-nix.nix
@@ -25,9 +25,9 @@
 # * enabling/disabling certain features in packages
 #
 # If you have an override of this kind, see configuration-common.nix instead.
-{ pkgs }:
+{ pkgs, haskellLib }:
 
-with import ./lib.nix { inherit pkgs; };
+with haskellLib;
 
 # All of the overrides in this set should look like:
 #
diff --git a/pkgs/development/haskell-modules/default.nix b/pkgs/development/haskell-modules/default.nix
index 32fa46f111dd..1658ce793936 100644
--- a/pkgs/development/haskell-modules/default.nix
+++ b/pkgs/development/haskell-modules/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, stdenv, ghc, all-cabal-hashes
+{ pkgs, stdenv, lib, haskellLib, ghc, all-cabal-hashes
 , compilerConfig ? (self: super: {})
 , packageSetConfig ? (self: super: {})
 , overrides ? (self: super: {})
@@ -9,16 +9,16 @@
 
 let
 
-  inherit (stdenv.lib) extends makeExtensible;
-  inherit (import ./lib.nix { inherit pkgs; }) overrideCabal makePackageSet;
+  inherit (lib) extends makeExtensible;
+  inherit (haskellLib) overrideCabal makePackageSet;
 
-  haskellPackages = makePackageSet {
+  haskellPackages = pkgs.callPackage makePackageSet {
     package-set = initialPackages;
-    inherit ghc extensible-self;
+    inherit stdenv haskellLib ghc extensible-self;
   };
 
-  commonConfiguration = configurationCommon { inherit pkgs; };
-  nixConfiguration = configurationNix { inherit pkgs; };
+  commonConfiguration = configurationCommon { inherit pkgs haskellLib; };
+  nixConfiguration = configurationNix { inherit pkgs haskellLib; };
 
   extensible-self = makeExtensible
     (extends overrides
diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix
index 30d82d3efc93..c67b61acd78d 100644
--- a/pkgs/development/haskell-modules/lib.nix
+++ b/pkgs/development/haskell-modules/lib.nix
@@ -1,7 +1,9 @@
-{ pkgs }:
+# TODO(@Ericson2314): Remove `pkgs` param, which is only used for
+# `buildStackProject` and `justStaticExecutables`
+{ pkgs, lib }:
 
 rec {
-  makePackageSet = pkgs.callPackage ./make-package-set.nix {};
+  makePackageSet = import ./make-package-set.nix;
 
   overrideCabal = drv: f: (drv.override (args: args // {
     mkDerivation = drv: (args.mkDerivation drv).override f;
@@ -25,7 +27,7 @@ rec {
   dontDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = []; });
 
   appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
-  removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = pkgs.stdenv.lib.remove x (drv.configureFlags or []); });
+  removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = lib.remove x (drv.configureFlags or []); });
 
   addBuildTool = drv: x: addBuildTools drv [x];
   addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });
@@ -71,7 +73,7 @@ rec {
 
   disableHardening = drv: flags: overrideCabal drv (drv: { hardeningDisable = flags; });
 
-  sdistTarball = pkg: pkgs.lib.overrideDerivation pkg (drv: {
+  sdistTarball = pkg: lib.overrideDerivation pkg (drv: {
     name = "${drv.pname}-source-${drv.version}";
     buildPhase = "./Setup sdist";
     haddockPhase = ":";
@@ -89,12 +91,11 @@ rec {
     isLibrary = false;
     doHaddock = false;
     postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
-  } // (if pkgs.stdenv.isDarwin then {
+  } // lib.optionalAttrs (pkgs.hostPlatform.isDarwin) {
     configureFlags = (drv.configureFlags or []) ++ ["--ghc-option=-optl=-dead_strip"];
-  } else {})
-  );
+  });
 
-  buildFromSdist = pkg: pkgs.lib.overrideDerivation pkg (drv: {
+  buildFromSdist = pkg: lib.overrideDerivation pkg (drv: {
     unpackPhase = let src = sdistTarball pkg; tarname = "${pkg.pname}-${pkg.version}"; in ''
       echo "Source tarball is at ${src}/${tarname}.tar.gz"
       tar xf ${src}/${tarname}.tar.gz
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix
index 6ed8d0864cac..87f3a04ebf57 100644
--- a/pkgs/development/haskell-modules/make-package-set.nix
+++ b/pkgs/development/haskell-modules/make-package-set.nix
@@ -1,20 +1,34 @@
 # This expression takes a file like `hackage-packages.nix` and constructs
 # a full package set out of that.
 
-# required dependencies:
-{ pkgs, stdenv, all-cabal-hashes }:
+{ # package-set used for non-haskell dependencies (all of nixpkgs)
+  pkgs
 
-# arguments:
-#  * ghc package to use
-#  * package-set: a function that takes { pkgs, stdenv, callPackage } as first arg and `self` as second
-#  * extensible-self: the final, fully overriden package set usable with the nixpkgs fixpoint overriding functionality
-{ ghc, package-set, extensible-self }:
+, # stdenv to use for building haskell packages
+  stdenv
+
+, haskellLib
+
+, # hashes for downloading Hackage packages
+  all-cabal-hashes
+
+, # compiler to use
+  ghc
+
+, # A function that takes `{ pkgs, stdenv, callPackage }` as the first arg and `self`
+  # as second, and returns a set of haskell packages
+  package-set
+
+, # The final, fully overriden package set usable with the nixpkgs fixpoint
+  # overriding functionality
+  extensible-self
+}:
 
 # return value: a function from self to the package set
 self: let
 
   inherit (stdenv.lib) fix' extends makeOverridable;
-  inherit (import ./lib.nix { inherit pkgs; }) overrideCabal;
+  inherit (haskellLib) overrideCabal;
 
   mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
     inherit stdenv;
diff --git a/pkgs/development/tools/haskell/lambdabot/default.nix b/pkgs/development/tools/haskell/lambdabot/default.nix
index 85d4bfc93b6a..7282fb4970ee 100644
--- a/pkgs/development/tools/haskell/lambdabot/default.nix
+++ b/pkgs/development/tools/haskell/lambdabot/default.nix
@@ -1,4 +1,4 @@
-{ lib, haskell-lib, fetchpatch, makeWrapper, haskellPackages
+{ lib, haskellLib, fetchpatch, makeWrapper, haskellPackages
 , mueval
 , withDjinn ? true
 , aspell ? null
@@ -25,7 +25,7 @@ let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ pac
     modulesStr = lib.replaceChars ["\n"] [" "] modules;
     configStr = lib.replaceChars ["\n"] [" "] configuration;
 
-in haskell-lib.overrideCabal haskellPackages.lambdabot (self: {
+in haskellLib.overrideCabal haskellPackages.lambdabot (self: {
   patches = (self.patches or []) ++ [ ./custom-config.patch ];
   postPatch = (self.postPatch or "") + ''
     substituteInPlace src/Main.hs \