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.
This commit is contained in:
parent
a2825a3c6f
commit
74f5fe5068
@ -9,9 +9,9 @@
|
|||||||
#
|
#
|
||||||
# See comment at the top of configuration-nix.nix for more information about this
|
# See comment at the top of configuration-nix.nix for more information about this
|
||||||
# distinction.
|
# distinction.
|
||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
#
|
#
|
||||||
# Please insert new packages *alphabetically*
|
# Please insert new packages *alphabetically*
|
||||||
# in the OTHER PACKAGES section.
|
# in the OTHER PACKAGES section.
|
||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
let
|
let
|
||||||
removeLibraryHaskellDepends = pnames: depends:
|
removeLibraryHaskellDepends = pnames: depends:
|
||||||
builtins.filter (e: !(builtins.elem (e.pname or "") pnames)) depends;
|
builtins.filter (e: !(builtins.elem (e.pname or "") pnames)) depends;
|
||||||
in
|
in
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super:
|
self: super:
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{ pkgs }:
|
{ pkgs, haskellLib }:
|
||||||
|
|
||||||
with import ./lib.nix { inherit pkgs; };
|
with haskellLib;
|
||||||
|
|
||||||
self: super: {
|
self: super: {
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@
|
|||||||
# * enabling/disabling certain features in packages
|
# * enabling/disabling certain features in packages
|
||||||
#
|
#
|
||||||
# If you have an override of this kind, see configuration-common.nix instead.
|
# 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:
|
# All of the overrides in this set should look like:
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ pkgs, stdenv, ghc, all-cabal-hashes
|
{ pkgs, stdenv, lib, haskellLib, ghc, all-cabal-hashes
|
||||||
, compilerConfig ? (self: super: {})
|
, compilerConfig ? (self: super: {})
|
||||||
, packageSetConfig ? (self: super: {})
|
, packageSetConfig ? (self: super: {})
|
||||||
, overrides ? (self: super: {})
|
, overrides ? (self: super: {})
|
||||||
@ -9,16 +9,16 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
inherit (stdenv.lib) extends makeExtensible;
|
inherit (lib) extends makeExtensible;
|
||||||
inherit (import ./lib.nix { inherit pkgs; }) overrideCabal makePackageSet;
|
inherit (haskellLib) overrideCabal makePackageSet;
|
||||||
|
|
||||||
haskellPackages = makePackageSet {
|
haskellPackages = pkgs.callPackage makePackageSet {
|
||||||
package-set = initialPackages;
|
package-set = initialPackages;
|
||||||
inherit ghc extensible-self;
|
inherit stdenv haskellLib ghc extensible-self;
|
||||||
};
|
};
|
||||||
|
|
||||||
commonConfiguration = configurationCommon { inherit pkgs; };
|
commonConfiguration = configurationCommon { inherit pkgs haskellLib; };
|
||||||
nixConfiguration = configurationNix { inherit pkgs; };
|
nixConfiguration = configurationNix { inherit pkgs haskellLib; };
|
||||||
|
|
||||||
extensible-self = makeExtensible
|
extensible-self = makeExtensible
|
||||||
(extends overrides
|
(extends overrides
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
{ pkgs }:
|
# TODO(@Ericson2314): Remove `pkgs` param, which is only used for
|
||||||
|
# `buildStackProject` and `justStaticExecutables`
|
||||||
|
{ pkgs, lib }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
makePackageSet = pkgs.callPackage ./make-package-set.nix {};
|
makePackageSet = import ./make-package-set.nix;
|
||||||
|
|
||||||
overrideCabal = drv: f: (drv.override (args: args // {
|
overrideCabal = drv: f: (drv.override (args: args // {
|
||||||
mkDerivation = drv: (args.mkDerivation drv).override f;
|
mkDerivation = drv: (args.mkDerivation drv).override f;
|
||||||
@ -25,7 +27,7 @@ rec {
|
|||||||
dontDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = []; });
|
dontDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = []; });
|
||||||
|
|
||||||
appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
|
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];
|
addBuildTool = drv: x: addBuildTools drv [x];
|
||||||
addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });
|
addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });
|
||||||
@ -71,7 +73,7 @@ rec {
|
|||||||
|
|
||||||
disableHardening = drv: flags: overrideCabal drv (drv: { hardeningDisable = flags; });
|
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}";
|
name = "${drv.pname}-source-${drv.version}";
|
||||||
buildPhase = "./Setup sdist";
|
buildPhase = "./Setup sdist";
|
||||||
haddockPhase = ":";
|
haddockPhase = ":";
|
||||||
@ -89,12 +91,11 @@ rec {
|
|||||||
isLibrary = false;
|
isLibrary = false;
|
||||||
doHaddock = false;
|
doHaddock = false;
|
||||||
postFixup = "rm -rf $out/lib $out/nix-support $out/share/doc";
|
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"];
|
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 ''
|
unpackPhase = let src = sdistTarball pkg; tarname = "${pkg.pname}-${pkg.version}"; in ''
|
||||||
echo "Source tarball is at ${src}/${tarname}.tar.gz"
|
echo "Source tarball is at ${src}/${tarname}.tar.gz"
|
||||||
tar xf ${src}/${tarname}.tar.gz
|
tar xf ${src}/${tarname}.tar.gz
|
||||||
|
@ -1,20 +1,34 @@
|
|||||||
# This expression takes a file like `hackage-packages.nix` and constructs
|
# This expression takes a file like `hackage-packages.nix` and constructs
|
||||||
# a full package set out of that.
|
# a full package set out of that.
|
||||||
|
|
||||||
# required dependencies:
|
{ # package-set used for non-haskell dependencies (all of nixpkgs)
|
||||||
{ pkgs, stdenv, all-cabal-hashes }:
|
pkgs
|
||||||
|
|
||||||
# arguments:
|
, # stdenv to use for building haskell packages
|
||||||
# * ghc package to use
|
stdenv
|
||||||
# * 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
|
, haskellLib
|
||||||
{ ghc, package-set, extensible-self }:
|
|
||||||
|
, # 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
|
# return value: a function from self to the package set
|
||||||
self: let
|
self: let
|
||||||
|
|
||||||
inherit (stdenv.lib) fix' extends makeOverridable;
|
inherit (stdenv.lib) fix' extends makeOverridable;
|
||||||
inherit (import ./lib.nix { inherit pkgs; }) overrideCabal;
|
inherit (haskellLib) overrideCabal;
|
||||||
|
|
||||||
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
|
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
|
||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ lib, haskell-lib, fetchpatch, makeWrapper, haskellPackages
|
{ lib, haskellLib, fetchpatch, makeWrapper, haskellPackages
|
||||||
, mueval
|
, mueval
|
||||||
, withDjinn ? true
|
, withDjinn ? true
|
||||||
, aspell ? null
|
, aspell ? null
|
||||||
@ -25,7 +25,7 @@ let allPkgs = pkgs: mueval.defaultPkgs pkgs ++ [ pkgs.lambdabot-trusted ] ++ pac
|
|||||||
modulesStr = lib.replaceChars ["\n"] [" "] modules;
|
modulesStr = lib.replaceChars ["\n"] [" "] modules;
|
||||||
configStr = lib.replaceChars ["\n"] [" "] configuration;
|
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 ];
|
patches = (self.patches or []) ++ [ ./custom-config.patch ];
|
||||||
postPatch = (self.postPatch or "") + ''
|
postPatch = (self.postPatch or "") + ''
|
||||||
substituteInPlace src/Main.hs \
|
substituteInPlace src/Main.hs \
|
||||||
|
@ -10085,7 +10085,7 @@ with pkgs;
|
|||||||
readosm = callPackage ../development/libraries/readosm { };
|
readosm = callPackage ../development/libraries/readosm { };
|
||||||
|
|
||||||
lambdabot = callPackage ../development/tools/haskell/lambdabot {
|
lambdabot = callPackage ../development/tools/haskell/lambdabot {
|
||||||
haskell-lib = haskell.lib;
|
haskellLib = haskell.lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
lambda-mod-zsh-theme = callPackage ../shells/lambda-mod-zsh-theme/default.nix { };
|
lambda-mod-zsh-theme = callPackage ../shells/lambda-mod-zsh-theme/default.nix { };
|
||||||
|
@ -1,24 +1,32 @@
|
|||||||
{ pkgs, callPackage, stdenv, buildPlatform, targetPlatform }:
|
{ pkgs, lib, newScope, stdenv, buildPlatform, targetPlatform }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# These are attributes in compiler and packages that don't support integer-simple.
|
||||||
|
integerSimpleExcludes = [
|
||||||
|
"ghc6102Binary"
|
||||||
|
"ghc704Binary"
|
||||||
|
"ghc742Binary"
|
||||||
|
"ghc6104"
|
||||||
|
"ghc6123"
|
||||||
|
"ghc704"
|
||||||
|
"ghc763"
|
||||||
|
"ghcjs"
|
||||||
|
"ghcjsHEAD"
|
||||||
|
"ghcCross"
|
||||||
|
"jhc"
|
||||||
|
"uhc"
|
||||||
|
"integer-simple"
|
||||||
|
];
|
||||||
|
|
||||||
|
haskellLib = import ../development/haskell-modules/lib.nix {
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
inherit pkgs;
|
||||||
|
};
|
||||||
|
|
||||||
|
callPackage = newScope { inherit haskellLib; };
|
||||||
|
|
||||||
let # These are attributes in compiler and packages that don't support integer-simple.
|
|
||||||
integerSimpleExcludes = [
|
|
||||||
"ghc6102Binary"
|
|
||||||
"ghc704Binary"
|
|
||||||
"ghc742Binary"
|
|
||||||
"ghc6104"
|
|
||||||
"ghc6123"
|
|
||||||
"ghc704"
|
|
||||||
"ghc763"
|
|
||||||
"ghcjs"
|
|
||||||
"ghcjsHEAD"
|
|
||||||
"ghcCross"
|
|
||||||
"jhc"
|
|
||||||
"uhc"
|
|
||||||
"integer-simple"
|
|
||||||
];
|
|
||||||
in rec {
|
in rec {
|
||||||
|
lib = haskellLib;
|
||||||
lib = import ../development/haskell-modules/lib.nix { inherit pkgs; };
|
|
||||||
|
|
||||||
compiler = {
|
compiler = {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user