git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit74f5fe50681003f075bf0b1ff811d0c0cd7c64f3 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateTue 1 Aug 2017, 12:44 (9 years ago) parenta2825a3
20 files changed+96−73
pkgs/development/haskell-modules/configuration-common.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix+2−2 pkgs/development/haskell-modules/configuration-ghc-head.nix+2−2 pkgs/development/haskell-modules/configuration-ghcjs.nix+2−2 pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix+2−2 pkgs/development/haskell-modules/configuration-nix.nix+2−2 pkgs/development/haskell-modules/default.nix+7−7 pkgs/development/haskell-modules/lib.nix+9−8 pkgs/development/haskell-modules/make-package-set.nix+22−8 pkgs/development/tools/haskell/lambdabot/default.nix+2−2 pkgs/top-level/all-packages.nix+1−1 pkgs/top-level/haskell-packages.nix+27−19
pkgs/development/haskell-modules/configuration-common.nix+2−2
@@ -9,9 +9,9 @@
99#
1010# See comment at the top of configuration-nix.nix for more information about this
1111# distinction.
12−{ pkgs }:
12+{ pkgs, haskellLib }:
1313
14−with import ./lib.nix { inherit pkgs; };
14+with haskellLib;
1515
1616self: super: {
1717
pkgs/development/haskell-modules/configuration-ghc-6.12.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-7.0.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-7.10.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-7.2.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-7.4.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-7.6.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-7.8.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-8.2.x.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghc-head.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-ghcjs.nix+2−2
@@ -2,14 +2,14 @@
22#
33# Please insert new packages *alphabetically*
44# in the OTHER PACKAGES section.
5−{ pkgs }:
5+{ pkgs, haskellLib }:
66
77let
88 removeLibraryHaskellDepends = pnames: depends:
99 builtins.filter (e: !(builtins.elem (e.pname or "") pnames)) depends;
1010in
1111
12−with import ./lib.nix { inherit pkgs; };
12+with haskellLib;
1313
1414self: super:
1515
pkgs/development/haskell-modules/configuration-halvm-2.4.0.nix+2−2
@@ -1,6 +1,6 @@
1−{ pkgs }:
1+{ pkgs, haskellLib }:
22
3−with import ./lib.nix { inherit pkgs; };
3+with haskellLib;
44
55self: super: {
66
pkgs/development/haskell-modules/configuration-nix.nix+2−2
@@ -25,9 +25,9 @@
2525# * enabling/disabling certain features in packages
2626#
2727# If you have an override of this kind, see configuration-common.nix instead.
28−{ pkgs }:
28+{ pkgs, haskellLib }:
2929
30−with import ./lib.nix { inherit pkgs; };
30+with haskellLib;
3131
3232# All of the overrides in this set should look like:
3333#
pkgs/development/haskell-modules/default.nix+7−7
@@ -1,4 +1,4 @@
1−{ pkgs, stdenv, ghc, all-cabal-hashes
1+{ pkgs, stdenv, lib, haskellLib, ghc, all-cabal-hashes
22, compilerConfig ? (self: super: {})
33, packageSetConfig ? (self: super: {})
44, overrides ? (self: super: {})
@@ -9,16 +9,16 @@
99
1010let
1111
12− inherit (stdenv.lib) extends makeExtensible;
13− inherit (import ./lib.nix { inherit pkgs; }) overrideCabal makePackageSet;
12+ inherit (lib) extends makeExtensible;
13+ inherit (haskellLib) overrideCabal makePackageSet;
1414
15− haskellPackages = makePackageSet {
15+ haskellPackages = pkgs.callPackage makePackageSet {
1616 package-set = initialPackages;
17− inherit ghc extensible-self;
17+ inherit stdenv haskellLib ghc extensible-self;
1818 };
1919
20− commonConfiguration = configurationCommon { inherit pkgs; };
21− nixConfiguration = configurationNix { inherit pkgs; };
20+ commonConfiguration = configurationCommon { inherit pkgs haskellLib; };
21+ nixConfiguration = configurationNix { inherit pkgs haskellLib; };
2222
2323 extensible-self = makeExtensible
2424 (extends overrides
pkgs/development/haskell-modules/lib.nix+9−8
@@ -1,7 +1,9 @@
1−{ pkgs }:
1+# TODO(@Ericson2314): Remove `pkgs` param, which is only used for
2+# `buildStackProject` and `justStaticExecutables`
3+{ pkgs, lib }:
24
35rec {
4− makePackageSet = pkgs.callPackage ./make-package-set.nix {};
6+ makePackageSet = import ./make-package-set.nix;
57
68 overrideCabal = drv: f: (drv.override (args: args // {
79 mkDerivation = drv: (args.mkDerivation drv).override f;
@@ -25,7 +27,7 @@ rec {
2527 dontDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = []; });
2628
2729 appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
28− removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = pkgs.stdenv.lib.remove x (drv.configureFlags or []); });
30+ removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = lib.remove x (drv.configureFlags or []); });
2931
3032 addBuildTool = drv: x: addBuildTools drv [x];
3133 addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });
@@ -71,7 +73,7 @@ rec {
7173
7274 disableHardening = drv: flags: overrideCabal drv (drv: { hardeningDisable = flags; });
7375
74− sdistTarball = pkg: pkgs.lib.overrideDerivation pkg (drv: {
76+ sdistTarball = pkg: lib.overrideDerivation pkg (drv: {
7577 name = "${drv.pname}-source-${drv.version}";
7678 buildPhase = "./Setup sdist";
7779 haddockPhase = ":";
@@ -89,12 +91,11 @@ rec {
8991 isLibrary = false;
9092 doHaddock = false;
9193 postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
92− } // (if pkgs.stdenv.isDarwin then {
94+ } // lib.optionalAttrs (pkgs.hostPlatform.isDarwin) {
9395 configureFlags = (drv.configureFlags or []) ++ ["--ghc-option=-optl=-dead_strip"];
94− } else {})
95− );
96+ });
9697
97− buildFromSdist = pkg: pkgs.lib.overrideDerivation pkg (drv: {
98+ buildFromSdist = pkg: lib.overrideDerivation pkg (drv: {
9899 unpackPhase = let src = sdistTarball pkg; tarname = "${pkg.pname}-${pkg.version}"; in ''
99100 echo "Source tarball is at ${src}/${tarname}.tar.gz"
100101 tar xf ${src}/${tarname}.tar.gz
pkgs/development/haskell-modules/make-package-set.nix+22−8
@@ -1,20 +1,34 @@
11# This expression takes a file like `hackage-packages.nix` and constructs
22# a full package set out of that.
33
4−# required dependencies:
5−{ pkgs, stdenv, all-cabal-hashes }:
4+{ # package-set used for non-haskell dependencies (all of nixpkgs)
5+ pkgs
66
7−# arguments:
8−# * ghc package to use
9−# * package-set: a function that takes { pkgs, stdenv, callPackage } as first arg and `self` as second
10−# * extensible-self: the final, fully overriden package set usable with the nixpkgs fixpoint overriding functionality
11−{ ghc, package-set, extensible-self }:
7+, # stdenv to use for building haskell packages
8+ stdenv
9+
10+, haskellLib
11+
12+, # hashes for downloading Hackage packages
13+ all-cabal-hashes
14+
15+, # compiler to use
16+ ghc
17+
18+, # A function that takes `{ pkgs, stdenv, callPackage }` as the first arg and `self`
19+ # as second, and returns a set of haskell packages
20+ package-set
21+
22+, # The final, fully overriden package set usable with the nixpkgs fixpoint
23+ # overriding functionality
24+ extensible-self
25+}:
1226
1327# return value: a function from self to the package set
1428self: let
1529
1630 inherit (stdenv.lib) fix' extends makeOverridable;
17− inherit (import ./lib.nix { inherit pkgs; }) overrideCabal;
31+ inherit (haskellLib) overrideCabal;
1832
1933 mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
2034 inherit stdenv;
pkgs/development/tools/haskell/lambdabot/default.nix+2−2
@@ -1,4 +1,4 @@
1−{ lib, haskell-lib, fetchpatch, makeWrapper, haskellPackages
1+{ lib, haskellLib, fetchpatch, makeWrapper, haskellPackages
22, mueval
33, withDjinn ? true
44, aspell ? null
@@ -25,7 +25,7 @@ let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ pac
2525 modulesStr = lib.replaceChars ["\n"] [" "] modules;
2626 configStr = lib.replaceChars ["\n"] [" "] configuration;
2727
28−in haskell-lib.overrideCabal haskellPackages.lambdabot (self: {
28+in haskellLib.overrideCabal haskellPackages.lambdabot (self: {
2929 patches = (self.patches or []) ++ [ ./custom-config.patch ];
3030 postPatch = (self.postPatch or "") + ''
3131 substituteInPlace src/Main.hs \
pkgs/top-level/all-packages.nix+1−1
@@ -10085,7 +10085,7 @@ with pkgs;
1008510085 readosm = callPackage ../development/libraries/readosm { };
1008610086
1008710087 lambdabot = callPackage ../development/tools/haskell/lambdabot {
10088− haskell-lib = haskell.lib;
10088+ haskellLib = haskell.lib;
1008910089 };
1009010090
1009110091 lambda-mod-zsh-theme = callPackage ../shells/lambda-mod-zsh-theme/default.nix { };
pkgs/top-level/haskell-packages.nix+27−19
@@ -1,24 +1,32 @@
1−{ pkgs, callPackage, stdenv, buildPlatform, targetPlatform }:
1+{ pkgs, lib, newScope, stdenv, buildPlatform, targetPlatform }:
22
3−let # These are attributes in compiler and packages that don't support integer-simple.
4− integerSimpleExcludes = [
5− "ghc6102Binary"
6− "ghc704Binary"
7− "ghc742Binary"
8− "ghc6104"
9− "ghc6123"
10− "ghc704"
11− "ghc763"
12− "ghcjs"
13− "ghcjsHEAD"
14− "ghcCross"
15− "jhc"
16− "uhc"
17− "integer-simple"
18− ];
19−in rec {
3+let
4+ # These are attributes in compiler and packages that don't support integer-simple.
5+ integerSimpleExcludes = [
6+ "ghc6102Binary"
7+ "ghc704Binary"
8+ "ghc742Binary"
9+ "ghc6104"
10+ "ghc6123"
11+ "ghc704"
12+ "ghc763"
13+ "ghcjs"
14+ "ghcjsHEAD"
15+ "ghcCross"
16+ "jhc"
17+ "uhc"
18+ "integer-simple"
19+ ];
20+
21+ haskellLib = import ../development/haskell-modules/lib.nix {
22+ inherit (pkgs) lib;
23+ inherit pkgs;
24+ };
2025
21− lib = import ../development/haskell-modules/lib.nix { inherit pkgs; };
26+ callPackage = newScope { inherit haskellLib; };
27+
28+in rec {
29+ lib = haskellLib;
2230
2331 compiler = {
2432